summaryrefslogtreecommitdiff
path: root/parse.go
diff options
context:
space:
mode:
authorAndrew Morozko <[email protected]>2019-11-30 00:22:21 +0300
committerAndrew Morozko <[email protected]>2019-11-30 00:22:21 +0300
commitc3a019cdb8116ae3b4a928c2a14efd83df7f34aa (patch)
tree04b6fdab240fb204221af4a500ca170eaf3972fd /parse.go
parent904e03926794663089b73d52a02def065d819200 (diff)
Various changes
Diffstat (limited to 'parse.go')
-rw-r--r--parse.go33
1 files changed, 18 insertions, 15 deletions
diff --git a/parse.go b/parse.go
index 3e1d719..5d3edec 100644
--- a/parse.go
+++ b/parse.go
@@ -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