diff options
| author | Andrew Morozko <[email protected]> | 2019-11-30 00:22:21 +0300 |
|---|---|---|
| committer | Andrew Morozko <[email protected]> | 2019-11-30 00:22:21 +0300 |
| commit | c3a019cdb8116ae3b4a928c2a14efd83df7f34aa (patch) | |
| tree | 04b6fdab240fb204221af4a500ca170eaf3972fd /parse.go | |
| parent | 904e03926794663089b73d52a02def065d819200 (diff) | |
Various changes
Diffstat (limited to 'parse.go')
| -rw-r--r-- | parse.go | 33 |
1 files changed, 18 insertions, 15 deletions
@@ -44,19 +44,19 @@ func (p path) Child(child string) path { // spec represents a command line option type spec struct { - dest path - typ reflect.Type - long string - short string - multiple bool - required bool - positional bool - separate bool - help string - env string - boolean bool - defaultVal string // default value for this option - dataname string // name of the data in help + dest path + typ reflect.Type + long string + short string + multiple bool + required bool + positional bool + separate bool + help string + env string + boolean bool + defaultVal string // default value for this option + placeholder string // name of the data in help } // command represents a named subcommand, or the top-level command @@ -345,8 +345,11 @@ func cmdFromStruct(name string, dest path, t reflect.Type) (*command, error) { } } - if spec.dataname == "" { - spec.dataname = strings.ToUpper(spec.long) + placeholder, hasPlaceholder := field.Tag.Lookup("placeholder") + if hasPlaceholder { + spec.placeholder = placeholder + } else { + spec.placeholder = strings.ToUpper(spec.long) } // Check whether this field is supported. It's good to do this here rather than |
