aboutsummaryrefslogtreecommitdiff
path: root/flag.go
diff options
context:
space:
mode:
authorEric Paris <[email protected]>2015-04-27 15:25:01 -0500
committerEric Paris <[email protected]>2015-04-27 15:25:01 -0500
commit08b1790a84badfb786d0cb0a60d6849630fc0d09 (patch)
tree424c2547ffc6c7a662bd375d4c271972c61c5700 /flag.go
parentbeb8d730f2afc6c3fe75312ad6f61a3dc47a64aa (diff)
parent4ac8829b5173e7af7ae84e1d477f8c5471cb126c (diff)
Merge pull request #13 from thockin/dash-under-equiv
Allow WordSeparators to be set after flags are added
Diffstat (limited to 'flag.go')
-rw-r--r--flag.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/flag.go b/flag.go
index 7af532e..5f14635 100644
--- a/flag.go
+++ b/flag.go
@@ -621,9 +621,14 @@ func SetInterspersed(interspersed bool) {
// SetWordSeparators sets a list of strings to be considerered as word
// separators and normalized for the pruposes of lookups. For example, if this
// is set to {"-", "_", "."} then --foo_bar, --foo-bar, and --foo.bar are
-// considered equivalent flags.
+// considered equivalent flags. This must be called before flags are parsed,
+// and may only be called once.
func (f *FlagSet) SetWordSeparators(separators []string) {
f.wordSeparators = separators
+ for k, v := range f.formal {
+ delete(f.formal, k)
+ f.formal[f.normalizeFlagName(string(k))] = v
+ }
}
// Parsed returns true if the command-line flags have been parsed.