aboutsummaryrefslogtreecommitdiff
path: root/flag.go
diff options
context:
space:
mode:
authorJordan Liggitt <[email protected]>2015-06-22 15:13:45 -0400
committerJordan Liggitt <[email protected]>2015-06-22 15:13:45 -0400
commit65c4dbac51b5ba2d6949a1e603cee33519a3a6b8 (patch)
treed56528e54ae45177d6f46fd316f02ec88dd0889a /flag.go
parent5644820622454e71517561946e3d94b9f9db6842 (diff)
Add SetAnnotation helper
Diffstat (limited to 'flag.go')
-rw-r--r--flag.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/flag.go b/flag.go
index 0070b93..42463c6 100644
--- a/flag.go
+++ b/flag.go
@@ -295,6 +295,19 @@ func (f *FlagSet) Set(name, value string) error {
return nil
}
+func (f *FlagSet) SetAnnotation(name, key string, values []string) error {
+ normalName := f.normalizeFlagName(name)
+ flag, ok := f.formal[normalName]
+ if !ok {
+ return fmt.Errorf("no such flag -%v", name)
+ }
+ if flag.Annotations == nil {
+ flag.Annotations = map[string][]string{}
+ }
+ flag.Annotations[key] = values
+ return nil
+}
+
// Set sets the value of the named command-line flag.
func Set(name, value string) error {
return CommandLine.Set(name, value)