diff options
| author | Alex Flint <[email protected]> | 2019-12-01 01:22:05 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-12-01 01:22:05 -0800 |
| commit | ced05bfe8a0f966d6ed09af656f5410bc5f4ed7c (patch) | |
| tree | 75a1540bde1cf3b46b45854e5043ca2100638888 /parse.go | |
| parent | c0c7a3ba8a1854cd85e65cca4f0e2028698a0738 (diff) | |
| parent | 9d4521ce8be4871b3ba85cb1bfa96f4b074f505b (diff) | |
Merge pull request #96 from Andrew-Morozko/master
Added the "placeholder" tag
Diffstat (limited to 'parse.go')
| -rw-r--r-- | parse.go | 32 |
1 files changed, 20 insertions, 12 deletions
@@ -44,18 +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 + 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 @@ -342,6 +343,13 @@ func cmdFromStruct(name string, dest path, t reflect.Type) (*command, error) { } } + 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 // wait until ParseValue because it means that a program with invalid argument // fields will always fail regardless of whether the arguments it received |
