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