Merge pull request #67 from johnSchnake/availableFlags
Add simple method to see if a flagset has available flags
diff --git a/flag.go b/flag.go
index deac3af..bb03cfc 100644
--- a/flag.go
+++ b/flag.go
@@ -242,6 +242,17 @@
return len(f.formal) > 0
}
+// HasAvailableFlags returns a bool to indicate if the FlagSet has any flags
+// definied that are not hidden or deprecated.
+func (f *FlagSet) HasAvailableFlags() bool {
+ for _, flag := range f.formal {
+ if !flag.Hidden && len(flag.Deprecated) == 0 {
+ return true
+ }
+ }
+ return false
+}
+
// VisitAll visits the command-line flags in lexicographical order, calling
// fn for each. It visits all flags, even those not set.
func VisitAll(fn func(*Flag)) {