summaryrefslogtreecommitdiff
path: root/parse.go
diff options
context:
space:
mode:
authorAlex Flint <[email protected]>2024-04-02 12:16:06 -0400
committerGitHub <[email protected]>2024-04-02 12:16:06 -0400
commitdfca71d1594a749ef5e2203e84cfb5a1b8e9387b (patch)
treeca10ce099d08b010cd3b7def62f30afdfcf07d10 /parse.go
parent188bd31bf60d57a7196c7547dd4bcd73298637ea (diff)
parentbe792f1f8b2f3971c54e00240ea35a53512ec7bf (diff)
Merge pull request #243 from alexflint/handle-empty-placeholderv1.5.0
Handle explicit empty placeholders
Diffstat (limited to 'parse.go')
-rw-r--r--parse.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/parse.go b/parse.go
index 45e4751..251b005 100644
--- a/parse.go
+++ b/parse.go
@@ -56,7 +56,7 @@ type spec struct {
env string // the name of the environment variable for this option, or empty for none
defaultValue reflect.Value // default value for this option
defaultString string // default value for this option, in string form to be displayed in help text
- placeholder string // name of the data in help
+ placeholder string // placeholder string in help
}
// command represents a named subcommand, or the top-level command
@@ -335,9 +335,8 @@ func cmdFromStruct(name string, dest path, t reflect.Type) (*command, error) {
spec.help = help
}
- // Look at the tag
- var isSubcommand bool // tracks whether this field is a subcommand
-
+ // process each comma-separated part of the tag
+ var isSubcommand bool
for _, key := range strings.Split(tag, ",") {
if key == "" {
continue
@@ -407,6 +406,7 @@ func cmdFromStruct(name string, dest path, t reflect.Type) (*command, error) {
}
}
+ // placeholder is the string used in the help text like this: "--somearg PLACEHOLDER"
placeholder, hasPlaceholder := field.Tag.Lookup("placeholder")
if hasPlaceholder {
spec.placeholder = placeholder