diff options
| author | Jordan Liggitt <[email protected]> | 2015-06-22 15:13:45 -0400 |
|---|---|---|
| committer | Jordan Liggitt <[email protected]> | 2015-06-22 15:13:45 -0400 |
| commit | 65c4dbac51b5ba2d6949a1e603cee33519a3a6b8 (patch) | |
| tree | d56528e54ae45177d6f46fd316f02ec88dd0889a /flag.go | |
| parent | 5644820622454e71517561946e3d94b9f9db6842 (diff) | |
Add SetAnnotation helper
Diffstat (limited to 'flag.go')
| -rw-r--r-- | flag.go | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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) |
