aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Paris <[email protected]>2015-03-13 13:04:38 -0400
committerspf13 <[email protected]>2015-04-01 16:32:26 -0400
commit18d831e92d67eafd1b0db8af9ffddbd04f7ae1f4 (patch)
tree3259728a53465b1b2f4723f369aeb7b0936528ed
parent11b7cf8387a31f278486eaad758162830eca8c73 (diff)
add annotations for flags
cobra.Command can make use of annotation in order to generate better bash_completions
-rw-r--r--flag.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/flag.go b/flag.go
index 72165f6..5dc5373 100644
--- a/flag.go
+++ b/flag.go
@@ -147,6 +147,7 @@ type Flag struct {
Value Value // value as set
DefValue string // default value (as text); for usage message
Changed bool // If the user set the value (or if left to default)
+ Annotations map[string][]string // used by cobra.Command bash autocomple code
}
// Value is the interface to the dynamic value stored in a flag.
@@ -358,7 +359,7 @@ func (f *FlagSet) Var(value Value, name string, usage string) {
// Like Var, but accepts a shorthand letter that can be used after a single dash.
func (f *FlagSet) VarP(value Value, name, shorthand, usage string) {
// Remember the default value as a string; it won't change.
- flag := &Flag{name, shorthand, usage, value, value.String(), false}
+ flag := &Flag{name, shorthand, usage, value, value.String(), false, make(map[string][]string)}
f.AddFlag(flag)
}