diff options
| author | Eric Paris <[email protected]> | 2015-08-07 18:19:17 -0400 |
|---|---|---|
| committer | Eric Paris <[email protected]> | 2015-08-07 18:26:20 -0400 |
| commit | 72d256dc0568ff0c62c58ad4e32b6b5fc0d533d8 (patch) | |
| tree | 2ff044d4ef04218719a62138c5778226cbd45228 /flag.go | |
| parent | 534019bcaea096fc0f0641afa2aed1e80cbb0ccc (diff) | |
New helper to easily see if a flag has been set
A lot easier than having to do it in the user over and over and over.
Diffstat (limited to 'flag.go')
| -rw-r--r-- | flag.go | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -330,6 +330,15 @@ func (f *FlagSet) SetAnnotation(name, key string, values []string) error { return nil } +func (f *FlagSet) Changed(name string) bool { + flag := f.Lookup(name) + // If a flag doesn't exist, it wasn't changed.... + if flag == nil { + return false + } + return flag.Changed +} + // Set sets the value of the named command-line flag. func Set(name, value string) error { return CommandLine.Set(name, value) |
