aboutsummaryrefslogtreecommitdiff
path: root/flag.go
diff options
context:
space:
mode:
authorEric Paris <[email protected]>2015-08-07 18:19:17 -0400
committerEric Paris <[email protected]>2015-08-07 18:26:20 -0400
commit72d256dc0568ff0c62c58ad4e32b6b5fc0d533d8 (patch)
tree2ff044d4ef04218719a62138c5778226cbd45228 /flag.go
parent534019bcaea096fc0f0641afa2aed1e80cbb0ccc (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.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/flag.go b/flag.go
index eba5fd9..c45ad0f 100644
--- a/flag.go
+++ b/flag.go
@@ -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)