@cryptotaxi247 / kubo / commits / 351ed9589

commands: Added 'Description' fields to Command, Argument, Option

Matt Bell committed Nov 7, 2014 at 20:56 UTC 351ed9589a5396f8dcfba38f0410a9100fdff712
3 files changed +12 -7
commands/argument.go
+5 -4
@@ -8,8 +8,9 @@ const (
8 )
9
10 type Argument struct {
11 - Name string
12 - Type ArgumentType
13 - Required bool
14 - Variadic bool
11 + Name string
12 + Type ArgumentType
13 + Required bool
14 + Variadic bool
15 + Description string
16 }
commands/command.go
+2
@@ -28,7 +28,9 @@ type Marshaller func(Response) ([]byte, error)
28 // Command is a runnable command, with input arguments and options (flags).
29 // It can also have Subcommands, to group units of work into sets.
30 type Command struct {
31 + Description string
32 Help string
33 +
34 Options []Option
35 Arguments []Argument
36 Run Function
commands/option.go
+5 -3
@@ -14,8 +14,9 @@ const (
14
15 // Option is used to specify a field that will be provided by a consumer
16 type Option struct {
17 - Names []string // a list of unique names to
18 - Type reflect.Kind // value must be this type
17 + Names []string // a list of unique names to
18 + Type reflect.Kind // value must be this type
19 + Description string // a short string to describe this option
20
21 // TODO: add more features(?):
22 //Default interface{} // the default value (ignored if `Required` is true)
@@ -30,7 +31,8 @@ const (
31
32 // options that are used by this package
33 var globalOptions = []Option{
33 - Option{[]string{EncShort, EncLong}, String},
34 + Option{[]string{EncShort, EncLong}, String,
35 + "The encoding type the output should be encoded with (json, xml, or text)"},
36 }
37
38 // the above array of Options, wrapped in a Command