summaryrefslogtreecommitdiff
path: root/parse.go
diff options
context:
space:
mode:
Diffstat (limited to 'parse.go')
-rw-r--r--parse.go32
1 files changed, 20 insertions, 12 deletions
diff --git a/parse.go b/parse.go
index bc156df..3fcf08a 100644
--- a/parse.go
+++ b/parse.go
@@ -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