Skip to content

Commit bf376a7

Browse files
authored
Update description for job and dataset commands (#385)
* Add more extensive description for job and dataset commands * remove global options from login command
1 parent a7e9147 commit bf376a7

File tree

6 files changed

+92
-56
lines changed

6 files changed

+92
-56
lines changed

Diff for: cmd/cmd.go

-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ func (cmd *command) Run(args []string) int {
134134
case errShowUsage:
135135
return cmd.usage(cause)
136136
case errShowHelp:
137-
cmd.out.Output(cause.Error())
138137
return cli.RunResultHelp
139138
default:
140139
return cmd.fail(err, "Error", false)

Diff for: cmd/dataset.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ func (cmd *Dataset) Execute(args []string) (err error) { return errShowHelp("")
2727
func (cmd *Dataset) Description() string { return cmd.Synopsis() }
2828

2929
// Synopsis returns a one-line
30-
func (cmd *Dataset) Synopsis() string { return "Manage job datasets." }
30+
func (cmd *Dataset) Synopsis() string {
31+
return "Manage datasets. A dataset is a collection of files, like a folder on a computer. They can be used as input for a job and, when an application creates output files, these can be automatically stored in a new dataset."
32+
}
3133

3234
// Usage shows usage
3335
func (cmd *Dataset) Usage() string { return "nerd dataset <subcommand>" }

Diff for: cmd/job.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ func (cmd *Job) Execute(args []string) (err error) { return errShowHelp("") }
2727
func (cmd *Job) Description() string { return cmd.Synopsis() }
2828

2929
// Synopsis returns a one-line
30-
func (cmd *Job) Synopsis() string { return "Manage the lifecycle of compute jobs." }
30+
func (cmd *Job) Synopsis() string {
31+
return "Manage the lifecycle of compute jobs. A job is a computation that takes some input data, runs an application to do operations on this data and stores the results."
32+
}
3133

3234
// Usage shows usage
3335
func (cmd *Job) Usage() string { return "nerd job <subcommand>" }

Diff for: main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ func create() *cli.CLI {
4949
"dataset delete": cmd.DatasetDeleteFactory(ui),
5050
"job": cmd.JobFactory(ui),
5151
"job run": cmd.JobRunFactory(ui),
52-
"job delete": cmd.JobDeleteFactory(ui),
5352
"job list": cmd.JobListFactory(ui),
5453
"job logs": cmd.JobLogsFactory(ui),
54+
"job delete": cmd.JobDeleteFactory(ui),
5555
},
5656
}
5757

Diff for: main_test.go

+3-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
flags "github.com/jessevdk/go-flags"
99
"github.com/mitchellh/cli"
10-
"github.com/nerdalize/nerd/command"
1110
)
1211

1312
//Documented can be implemented by command we want to have documented
@@ -37,8 +36,7 @@ func TestDocGeneration(t *testing.T) {
3736
}
3837

3938
type docs struct {
40-
GlobalOptions []opt `json:"global_options"`
41-
Commands map[string]*entry `json:"commands"`
39+
Commands map[string]*entry `json:"commands"`
4240
}
4341

4442
d := docs{
@@ -90,11 +88,7 @@ func TestDocGeneration(t *testing.T) {
9088
gopts = append(gopts, op)
9189
}
9290

93-
if g.LongDescription != command.SharedOptionsGroup {
94-
opts[g.LongDescription] = gopts
95-
} else {
96-
d.GlobalOptions = gopts
97-
}
91+
opts[g.LongDescription] = gopts
9892
}
9993

10094
}
@@ -103,14 +97,14 @@ func TestDocGeneration(t *testing.T) {
10397
if err != nil {
10498
t.Fatalf("failed to write docs: %v", err)
10599
}
100+
defer f.Close()
106101

107102
enc := json.NewEncoder(f)
108103
enc.SetIndent("", "\t")
109104
err = enc.Encode(d)
110105
if err != nil {
111106
t.Fatalf("failed to encode: %+v", err)
112107
}
113-
114108
}
115109

116110
func isNotSysCmd(cli *cli.CLI, name string) bool {

Diff for: spec.json

+82-43
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,9 @@
11
{
2-
"global_options": [
3-
{
4-
"long_name": "config-file",
5-
"description": "Location of config file",
6-
"default_value": [
7-
""
8-
],
9-
"choices": null
10-
},
11-
{
12-
"long_name": "session-file",
13-
"description": "Location of session file",
14-
"default_value": [
15-
""
16-
],
17-
"choices": null
18-
},
19-
{
20-
"long_name": "debug",
21-
"description": "Show debug output",
22-
"default_value": [
23-
"false"
24-
],
25-
"choices": null
26-
},
27-
{
28-
"long_name": "output",
29-
"description": "Format of the output",
30-
"default_value": [
31-
"pretty"
32-
],
33-
"choices": [
34-
"pretty",
35-
"raw",
36-
"json"
37-
]
38-
}
39-
],
402
"commands": {
413
"dataset": {
424
"usage": "nerd dataset \u003csubcommand\u003e",
43-
"synopsis": "Manage job datasets.",
44-
"description": "Manage job datasets.",
5+
"synopsis": "Manage datasets. A dataset is a collection of files, like a folder on a computer. They can be used as input for a job and, when an application creates output files, these can be automatically stored in a new dataset.",
6+
"description": "Manage datasets. A dataset is a collection of files, like a folder on a computer. They can be used as input for a job and, when an application creates output files, these can be automatically stored in a new dataset.",
457
"options": {
468
"Global Options": [
479
{
@@ -229,8 +191,8 @@
229191
},
230192
"job": {
231193
"usage": "nerd job \u003csubcommand\u003e",
232-
"synopsis": "Manage the lifecycle of compute jobs.",
233-
"description": "Manage the lifecycle of compute jobs.",
194+
"synopsis": "Manage the lifecycle of compute jobs. A job is a computation that takes some input data, runs an application to do operations on this data and stores the results.",
195+
"description": "Manage the lifecycle of compute jobs. A job is a computation that takes some input data, runs an application to do operations on this data and stores the results.",
234196
"options": {
235197
"Global Options": [
236198
{
@@ -479,14 +441,91 @@
479441
"default_value": null,
480442
"choices": null
481443
}
444+
],
445+
"Other Options": [
446+
{
447+
"long_name": "config-file",
448+
"description": "Location of config file",
449+
"default_value": [
450+
""
451+
],
452+
"choices": null
453+
},
454+
{
455+
"long_name": "session-file",
456+
"description": "Location of session file",
457+
"default_value": [
458+
""
459+
],
460+
"choices": null
461+
},
462+
{
463+
"long_name": "debug",
464+
"description": "Show debug output",
465+
"default_value": [
466+
"false"
467+
],
468+
"choices": null
469+
},
470+
{
471+
"long_name": "output",
472+
"description": "Format of the output",
473+
"default_value": [
474+
"pretty"
475+
],
476+
"choices": [
477+
"pretty",
478+
"raw",
479+
"json"
480+
]
481+
}
482482
]
483483
}
484484
},
485485
"version": {
486486
"usage": "nerd version",
487487
"synopsis": "Check the current version.",
488488
"description": "Check the current version.",
489-
"options": {}
489+
"options": {
490+
"Other Options": [
491+
{
492+
"long_name": "config-file",
493+
"description": "Location of config file",
494+
"default_value": [
495+
""
496+
],
497+
"choices": null
498+
},
499+
{
500+
"long_name": "session-file",
501+
"description": "Location of session file",
502+
"default_value": [
503+
""
504+
],
505+
"choices": null
506+
},
507+
{
508+
"long_name": "debug",
509+
"description": "Show debug output",
510+
"default_value": [
511+
"false"
512+
],
513+
"choices": null
514+
},
515+
{
516+
"long_name": "output",
517+
"description": "Format of the output",
518+
"default_value": [
519+
"pretty"
520+
],
521+
"choices": [
522+
"pretty",
523+
"raw",
524+
"json"
525+
]
526+
}
527+
]
528+
}
490529
}
491530
}
492531
}

0 commit comments

Comments
 (0)