aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Paris <[email protected]>2015-04-27 15:26:40 -0500
committerEric Paris <[email protected]>2015-04-27 15:26:40 -0500
commit60d4c375939ff7ba397a84117d5281256abb298f (patch)
treea1976cbfee71b25287763c986ee41aa1b8f45c08
parent5a5d661298302ebb7bf7fb205a37a566b0de94d7 (diff)
parentdb78b3f83a8d9270e6bdab11e0b94c26963ab3d2 (diff)
Merge pull request #10 from eparis/declare_by_name
Declare Flag{ by name instead of order
-rw-r--r--flag.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/flag.go b/flag.go
index 7fb0990..33db47c 100644
--- a/flag.go
+++ b/flag.go
@@ -379,7 +379,13 @@ 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, make(map[string][]string)}
+ flag := &Flag{
+ Name: name,
+ Shorthand: shorthand,
+ Usage: usage,
+ Value: value,
+ DefValue: value.String(),
+ }
f.AddFlag(flag)
}