add the [OPTIONS] string automatically if there are flags defined

Signed-off-by: SvenDowideit <SvenDowideit@home.org.au>

Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
This commit is contained in:
SvenDowideit 2014-08-25 11:53:31 +10:00
parent 1595a81343
commit cf3dfd3d8b
2 changed files with 46 additions and 0 deletions

View file

@ -472,6 +472,23 @@ var Usage = func() {
PrintDefaults()
}
// FlagCount returns the number of flags that have been defined.
func (f *FlagSet) FlagCount() int { return len(f.formal) }
// FlagCountUndeprecated returns the number of undeprecated flags that have been defined.
func (f *FlagSet) FlagCountUndeprecated() int {
count := 0
for _, flag := range sortFlags(f.formal) {
for _, name := range flag.Names {
if name[0] != '#' {
count++
break
}
}
}
return count
}
// NFlag returns the number of flags that have been set.
func (f *FlagSet) NFlag() int { return len(f.actual) }