diff options
| author | Andrew Morozko <[email protected]> | 2019-11-29 22:33:16 +0300 |
|---|---|---|
| committer | Andrew Morozko <[email protected]> | 2019-11-29 22:33:16 +0300 |
| commit | 904e03926794663089b73d52a02def065d819200 (patch) | |
| tree | 9355b68ec30c55a81968cd92280acd0f69281dcf /parse.go | |
| parent | c0c7a3ba8a1854cd85e65cca4f0e2028698a0738 (diff) | |
Added the "dataname" tag
Diffstat (limited to 'parse.go')
| -rw-r--r-- | parse.go | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -56,6 +56,7 @@ type spec struct { env string boolean bool defaultVal string // default value for this option + dataname string // name of the data in help } // command represents a named subcommand, or the top-level command @@ -305,6 +306,8 @@ func cmdFromStruct(name string, dest path, t reflect.Type) (*command, error) { spec.required = true case key == "positional": spec.positional = true + case key == "dataname": + spec.dataname = value case key == "separate": spec.separate = true case key == "help": // deprecated @@ -342,6 +345,10 @@ func cmdFromStruct(name string, dest path, t reflect.Type) (*command, error) { } } + if spec.dataname == "" { + spec.dataname = strings.ToUpper(spec.long) + } + // Check whether this field is supported. It's good to do this here rather than // wait until ParseValue because it means that a program with invalid argument // fields will always fail regardless of whether the arguments it received |
