提交 351ed958 作者: Matt Bell 提交者: Juan Batiz-Benet

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

上级 538dac15
...@@ -8,8 +8,9 @@ const ( ...@@ -8,8 +8,9 @@ const (
) )
type Argument struct { type Argument struct {
Name string Name string
Type ArgumentType Type ArgumentType
Required bool Required bool
Variadic bool Variadic bool
Description string
} }
...@@ -28,7 +28,9 @@ type Marshaller func(Response) ([]byte, error) ...@@ -28,7 +28,9 @@ type Marshaller func(Response) ([]byte, error)
// Command is a runnable command, with input arguments and options (flags). // Command is a runnable command, with input arguments and options (flags).
// It can also have Subcommands, to group units of work into sets. // It can also have Subcommands, to group units of work into sets.
type Command struct { type Command struct {
Description string
Help string Help string
Options []Option Options []Option
Arguments []Argument Arguments []Argument
Run Function Run Function
......
...@@ -14,8 +14,9 @@ const ( ...@@ -14,8 +14,9 @@ const (
// Option is used to specify a field that will be provided by a consumer // Option is used to specify a field that will be provided by a consumer
type Option struct { type Option struct {
Names []string // a list of unique names to Names []string // a list of unique names to
Type reflect.Kind // value must be this type Type reflect.Kind // value must be this type
Description string // a short string to describe this option
// TODO: add more features(?): // TODO: add more features(?):
//Default interface{} // the default value (ignored if `Required` is true) //Default interface{} // the default value (ignored if `Required` is true)
...@@ -30,7 +31,8 @@ const ( ...@@ -30,7 +31,8 @@ const (
// options that are used by this package // options that are used by this package
var globalOptions = []Option{ var globalOptions = []Option{
Option{[]string{EncShort, EncLong}, String}, Option{[]string{EncShort, EncLong}, String,
"The encoding type the output should be encoded with (json, xml, or text)"},
} }
// the above array of Options, wrapped in a Command // the above array of Options, wrapped in a Command
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论