diff options
Diffstat (limited to 'libgo/go/flag/flag.go')
-rw-r--r-- | libgo/go/flag/flag.go | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/libgo/go/flag/flag.go b/libgo/go/flag/flag.go index edde528..2cd7829 100644 --- a/libgo/go/flag/flag.go +++ b/libgo/go/flag/flag.go @@ -5,7 +5,7 @@ /* Package flag implements command-line flag parsing. - Usage: + Usage Define flags using flag.String(), Bool(), Int(), etc. @@ -35,7 +35,10 @@ slice flag.Args() or individually as flag.Arg(i). The arguments are indexed from 0 through flag.NArg()-1. - Command line flag syntax: + Command line flag syntax + + The following forms are permitted: + -flag -flag=x -flag x // non-boolean flags only @@ -395,8 +398,8 @@ func Set(name, value string) error { return CommandLine.Set(name, value) } -// isZeroValue guesses whether the string represents the zero -// value for a flag. It is not accurate but in practice works OK. +// isZeroValue determines whether the string represents the zero +// value for a flag. func isZeroValue(flag *Flag, value string) bool { // Build a zero value of the flag's Value type, and see if the // result of calling its String method equals the value passed in. @@ -408,15 +411,7 @@ func isZeroValue(flag *Flag, value string) bool { } else { z = reflect.Zero(typ) } - if value == z.Interface().(Value).String() { - return true - } - - switch value { - case "false", "", "0": - return true - } - return false + return value == z.Interface().(Value).String() } // UnquoteUsage extracts a back-quoted name from the usage @@ -981,7 +976,8 @@ func commandLineUsage() { } // NewFlagSet returns a new, empty flag set with the specified name and -// error handling property. +// error handling property. If the name is not empty, it will be printed +// in the default usage message and in error messages. func NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet { f := &FlagSet{ name: name, |