Skip to content

Commit

Permalink
Compatibility: commandLine -> CommandLine
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed Apr 2, 2014
1 parent f235ad3 commit e101bb9
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 89 deletions.
8 changes: 4 additions & 4 deletions bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ func (f *FlagSet) BoolVarP(p *bool, name, shorthand string, value bool, usage st
// BoolVar defines a bool flag with specified name, default value, and usage string.
// The argument p points to a bool variable in which to store the value of the flag.
func BoolVar(p *bool, name string, value bool, usage string) {
commandLine.VarP(newBoolValue(value, p), name, "", usage)
CommandLine.VarP(newBoolValue(value, p), name, "", usage)
}

// Like BoolVar, but accepts a shorthand letter that can be used after a single dash.
func BoolVarP(p *bool, name, shorthand string, value bool, usage string) {
commandLine.VarP(newBoolValue(value, p), name, shorthand, usage)
CommandLine.VarP(newBoolValue(value, p), name, shorthand, usage)
}

// Bool defines a bool flag with specified name, default value, and usage string.
Expand All @@ -61,10 +61,10 @@ func (f *FlagSet) BoolP(name, shorthand string, value bool, usage string) *bool
// Bool defines a bool flag with specified name, default value, and usage string.
// The return value is the address of a bool variable that stores the value of the flag.
func Bool(name string, value bool, usage string) *bool {
return commandLine.BoolP(name, "", value, usage)
return CommandLine.BoolP(name, "", value, usage)
}

// Like Bool, but accepts a shorthand letter that can be used after a single dash.
func BoolP(name, shorthand string, value bool, usage string) *bool {
return commandLine.BoolP(name, shorthand, value, usage)
return CommandLine.BoolP(name, shorthand, value, usage)
}
8 changes: 4 additions & 4 deletions duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ func (f *FlagSet) DurationVarP(p *time.Duration, name, shorthand string, value t
// DurationVar defines a time.Duration flag with specified name, default value, and usage string.
// The argument p points to a time.Duration variable in which to store the value of the flag.
func DurationVar(p *time.Duration, name string, value time.Duration, usage string) {
commandLine.VarP(newDurationValue(value, p), name, "", usage)
CommandLine.VarP(newDurationValue(value, p), name, "", usage)
}

// Like DurationVar, but accepts a shorthand letter that can be used after a single dash.
func DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string) {
commandLine.VarP(newDurationValue(value, p), name, shorthand, usage)
CommandLine.VarP(newDurationValue(value, p), name, shorthand, usage)
}

// Duration defines a time.Duration flag with specified name, default value, and usage string.
Expand All @@ -65,10 +65,10 @@ func (f *FlagSet) DurationP(name, shorthand string, value time.Duration, usage s
// Duration defines a time.Duration flag with specified name, default value, and usage string.
// The return value is the address of a time.Duration variable that stores the value of the flag.
func Duration(name string, value time.Duration, usage string) *time.Duration {
return commandLine.DurationP(name, "", value, usage)
return CommandLine.DurationP(name, "", value, usage)
}

// Like Duration, but accepts a shorthand letter that can be used after a single dash.
func DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration {
return commandLine.DurationP(name, shorthand, value, usage)
return CommandLine.DurationP(name, shorthand, value, usage)
}
6 changes: 3 additions & 3 deletions export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
// After calling ResetForTesting, parse errors in flag handling will not
// exit the program.
func ResetForTesting(usage func()) {
commandLine = &FlagSet{
CommandLine = &FlagSet{
name: os.Args[0],
errorHandling: ContinueOnError,
output: ioutil.Discard,
Expand All @@ -24,6 +24,6 @@ func ResetForTesting(usage func()) {
}

// CommandLine returns the default FlagSet.
func CommandLine() *FlagSet {
return commandLine
func GetCommandLine() *FlagSet {
return CommandLine
}
38 changes: 19 additions & 19 deletions flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (f *FlagSet) VisitAll(fn func(*Flag)) {
// 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)) {
commandLine.VisitAll(fn)
CommandLine.VisitAll(fn)
}

// Visit visits the flags in lexicographical order, calling fn for each.
Expand All @@ -201,7 +201,7 @@ func (f *FlagSet) Visit(fn func(*Flag)) {
// Visit visits the command-line flags in lexicographical order, calling fn
// for each. It visits only those flags that have been set.
func Visit(fn func(*Flag)) {
commandLine.Visit(fn)
CommandLine.Visit(fn)
}

// Lookup returns the Flag structure of the named flag, returning nil if none exists.
Expand All @@ -212,7 +212,7 @@ func (f *FlagSet) Lookup(name string) *Flag {
// Lookup returns the Flag structure of the named command-line flag,
// returning nil if none exists.
func Lookup(name string) *Flag {
return commandLine.formal[name]
return CommandLine.formal[name]
}

// Set sets the value of the named flag.
Expand All @@ -234,7 +234,7 @@ func (f *FlagSet) Set(name, value string) error {

// Set sets the value of the named command-line flag.
func Set(name, value string) error {
return commandLine.Set(name, value)
return CommandLine.Set(name, value)
}

// PrintDefaults prints, to standard error unless configured
Expand All @@ -257,7 +257,7 @@ func (f *FlagSet) PrintDefaults() {

// PrintDefaults prints to standard error the default values of all defined command-line flags.
func PrintDefaults() {
commandLine.PrintDefaults()
CommandLine.PrintDefaults()
}

// defaultUsage is the default function to print a usage message.
Expand All @@ -266,7 +266,7 @@ func defaultUsage(f *FlagSet) {
f.PrintDefaults()
}

// NOTE: Usage is not just defaultUsage(commandLine)
// NOTE: Usage is not just defaultUsage(CommandLine)
// because it serves (via godoc flag Usage) as the example
// for how to write your own usage function.

Expand All @@ -281,7 +281,7 @@ var Usage = func() {
func (f *FlagSet) NFlag() int { return len(f.actual) }

// NFlag returns the number of command-line flags that have been set.
func NFlag() int { return len(commandLine.actual) }
func NFlag() int { return len(CommandLine.actual) }

// Arg returns the i'th argument. Arg(0) is the first remaining argument
// after flags have been processed.
Expand All @@ -295,20 +295,20 @@ func (f *FlagSet) Arg(i int) string {
// Arg returns the i'th command-line argument. Arg(0) is the first remaining argument
// after flags have been processed.
func Arg(i int) string {
return commandLine.Arg(i)
return CommandLine.Arg(i)
}

// NArg is the number of arguments remaining after flags have been processed.
func (f *FlagSet) NArg() int { return len(f.args) }

// NArg is the number of arguments remaining after flags have been processed.
func NArg() int { return len(commandLine.args) }
func NArg() int { return len(CommandLine.args) }

// Args returns the non-flag arguments.
func (f *FlagSet) Args() []string { return f.args }

// Args returns the non-flag command-line arguments.
func Args() []string { return commandLine.args }
func Args() []string { return CommandLine.args }

// Var defines a flag with the specified name and usage string. The type and
// value of the flag are represented by the first argument, of type Value, which
Expand Down Expand Up @@ -361,12 +361,12 @@ func (f *FlagSet) VarP(value Value, name, shorthand, usage string) {
// of strings by giving the slice the methods of Value; in particular, Set would
// decompose the comma-separated string into the slice.
func Var(value Value, name string, usage string) {
commandLine.VarP(value, name, "", usage)
CommandLine.VarP(value, name, "", usage)
}

// Like Var, but accepts a shorthand letter that can be used after a single dash.
func VarP(value Value, name, shorthand, usage string) {
commandLine.VarP(value, name, shorthand, usage)
CommandLine.VarP(value, name, shorthand, usage)
}

// failf prints to standard error a formatted error and usage message and
Expand All @@ -379,9 +379,9 @@ func (f *FlagSet) failf(format string, a ...interface{}) error {
}

// usage calls the Usage method for the flag set, or the usage function if
// the flag set is commandLine.
// the flag set is CommandLine.
func (f *FlagSet) usage() {
if f == commandLine {
if f == CommandLine {
Usage()
} else if f.Usage == nil {
defaultUsage(f)
Expand Down Expand Up @@ -512,22 +512,22 @@ func (f *FlagSet) Parsed() bool {
// Parse parses the command-line flags from os.Args[1:]. Must be called
// after all flags are defined and before flags are accessed by the program.
func Parse() {
// Ignore errors; commandLine is set for ExitOnError.
commandLine.Parse(os.Args[1:])
// Ignore errors; CommandLine is set for ExitOnError.
CommandLine.Parse(os.Args[1:])
}

// Whether to support interspersed option/non-option arguments.
func SetInterspersed(interspersed bool) {
commandLine.SetInterspersed(interspersed)
CommandLine.SetInterspersed(interspersed)
}

// Parsed returns true if the command-line flags have been parsed.
func Parsed() bool {
return commandLine.Parsed()
return CommandLine.Parsed()
}

// The default set of command-line flags, parsed from os.Args.
var commandLine = NewFlagSet(os.Args[0], ExitOnError)
var CommandLine = NewFlagSet(os.Args[0], ExitOnError)

// NewFlagSet returns a new, empty flag set with the specified name and
// error handling property.
Expand Down
6 changes: 3 additions & 3 deletions flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestEverything(t *testing.T) {
func TestUsage(t *testing.T) {
called := false
ResetForTesting(func() { called = true })
if CommandLine().Parse([]string{"--x"}) == nil {
if GetCommandLine().Parse([]string{"--x"}) == nil {
t.Error("parse did not fail for unknown flag")
}
if !called {
Expand Down Expand Up @@ -224,7 +224,7 @@ func TestShorthand(t *testing.T) {

func TestParse(t *testing.T) {
ResetForTesting(func() { t.Error("bad parse") })
testParse(CommandLine(), t)
testParse(GetCommandLine(), t)
}

func TestFlagSetParse(t *testing.T) {
Expand Down Expand Up @@ -279,7 +279,7 @@ func TestChangingArgs(t *testing.T) {
defer func() { os.Args = oldArgs }()
os.Args = []string{"cmd", "--before", "subcmd"}
before := Bool("before", false, "")
if err := CommandLine().Parse(os.Args[1:]); err != nil {
if err := GetCommandLine().Parse(os.Args[1:]); err != nil {
t.Fatal(err)
}
cmd := Arg(0)
Expand Down
8 changes: 4 additions & 4 deletions float32.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ func (f *FlagSet) Float32VarP(p *float32, name, shorthand string, value float32,
// Float32Var defines a float32 flag with specified name, default value, and usage string.
// The argument p points to a float32 variable in which to store the value of the flag.
func Float32Var(p *float32, name string, value float32, usage string) {
commandLine.VarP(newFloat32Value(value, p), name, "", usage)
CommandLine.VarP(newFloat32Value(value, p), name, "", usage)
}

// Like Float32Var, but accepts a shorthand letter that can be used after a single dash.
func Float32VarP(p *float32, name, shorthand string, value float32, usage string) {
commandLine.VarP(newFloat32Value(value, p), name, shorthand, usage)
CommandLine.VarP(newFloat32Value(value, p), name, shorthand, usage)
}

// Float32 defines a float32 flag with specified name, default value, and usage string.
Expand All @@ -61,10 +61,10 @@ func (f *FlagSet) Float32P(name, shorthand string, value float32, usage string)
// Float32 defines a float32 flag with specified name, default value, and usage string.
// The return value is the address of a float32 variable that stores the value of the flag.
func Float32(name string, value float32, usage string) *float32 {
return commandLine.Float32P(name, "", value, usage)
return CommandLine.Float32P(name, "", value, usage)
}

// Like Float32, but accepts a shorthand letter that can be used after a single dash.
func Float32P(name, shorthand string, value float32, usage string) *float32 {
return commandLine.Float32P(name, shorthand, value, usage)
return CommandLine.Float32P(name, shorthand, value, usage)
}
8 changes: 4 additions & 4 deletions float64.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ func (f *FlagSet) Float64VarP(p *float64, name, shorthand string, value float64,
// Float64Var defines a float64 flag with specified name, default value, and usage string.
// The argument p points to a float64 variable in which to store the value of the flag.
func Float64Var(p *float64, name string, value float64, usage string) {
commandLine.VarP(newFloat64Value(value, p), name, "", usage)
CommandLine.VarP(newFloat64Value(value, p), name, "", usage)
}

// Like Float64Var, but accepts a shorthand letter that can be used after a single dash.
func Float64VarP(p *float64, name, shorthand string, value float64, usage string) {
commandLine.VarP(newFloat64Value(value, p), name, shorthand, usage)
CommandLine.VarP(newFloat64Value(value, p), name, shorthand, usage)
}

// Float64 defines a float64 flag with specified name, default value, and usage string.
Expand All @@ -61,10 +61,10 @@ func (f *FlagSet) Float64P(name, shorthand string, value float64, usage string)
// Float64 defines a float64 flag with specified name, default value, and usage string.
// The return value is the address of a float64 variable that stores the value of the flag.
func Float64(name string, value float64, usage string) *float64 {
return commandLine.Float64P(name, "", value, usage)
return CommandLine.Float64P(name, "", value, usage)
}

// Like Float64, but accepts a shorthand letter that can be used after a single dash.
func Float64P(name, shorthand string, value float64, usage string) *float64 {
return commandLine.Float64P(name, shorthand, value, usage)
return CommandLine.Float64P(name, shorthand, value, usage)
}
8 changes: 4 additions & 4 deletions int.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ func (f *FlagSet) IntVarP(p *int, name, shorthand string, value int, usage strin
// IntVar defines an int flag with specified name, default value, and usage string.
// The argument p points to an int variable in which to store the value of the flag.
func IntVar(p *int, name string, value int, usage string) {
commandLine.VarP(newIntValue(value, p), name, "", usage)
CommandLine.VarP(newIntValue(value, p), name, "", usage)
}

// Like IntVar, but accepts a shorthand letter that can be used after a single dash.
func IntVarP(p *int, name, shorthand string, value int, usage string) {
commandLine.VarP(newIntValue(value, p), name, shorthand, usage)
CommandLine.VarP(newIntValue(value, p), name, shorthand, usage)
}

// Int defines an int flag with specified name, default value, and usage string.
Expand All @@ -61,10 +61,10 @@ func (f *FlagSet) IntP(name, shorthand string, value int, usage string) *int {
// Int defines an int flag with specified name, default value, and usage string.
// The return value is the address of an int variable that stores the value of the flag.
func Int(name string, value int, usage string) *int {
return commandLine.IntP(name, "", value, usage)
return CommandLine.IntP(name, "", value, usage)
}

// Like Int, but accepts a shorthand letter that can be used after a single dash.
func IntP(name, shorthand string, value int, usage string) *int {
return commandLine.IntP(name, shorthand, value, usage)
return CommandLine.IntP(name, shorthand, value, usage)
}
8 changes: 4 additions & 4 deletions int32.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ func (f *FlagSet) Int32VarP(p *int32, name, shorthand string, value int32, usage
// Int32Var defines an int32 flag with specified name, default value, and usage string.
// The argument p points to an int32 variable in which to store the value of the flag.
func Int32Var(p *int32, name string, value int32, usage string) {
commandLine.VarP(newInt32Value(value, p), name, "", usage)
CommandLine.VarP(newInt32Value(value, p), name, "", usage)
}

// Like Int32Var, but accepts a shorthand letter that can be used after a single dash.
func Int32VarP(p *int32, name, shorthand string, value int32, usage string) {
commandLine.VarP(newInt32Value(value, p), name, shorthand, usage)
CommandLine.VarP(newInt32Value(value, p), name, shorthand, usage)
}

// Int32 defines an int32 flag with specified name, default value, and usage string.
Expand All @@ -61,10 +61,10 @@ func (f *FlagSet) Int32P(name, shorthand string, value int32, usage string) *int
// Int32 defines an int32 flag with specified name, default value, and usage string.
// The return value is the address of an int32 variable that stores the value of the flag.
func Int32(name string, value int32, usage string) *int32 {
return commandLine.Int32P(name, "", value, usage)
return CommandLine.Int32P(name, "", value, usage)
}

// Like Int32, but accepts a shorthand letter that can be used after a single dash.
func Int32P(name, shorthand string, value int32, usage string) *int32 {
return commandLine.Int32P(name, shorthand, value, usage)
return CommandLine.Int32P(name, shorthand, value, usage)
}
8 changes: 4 additions & 4 deletions int64.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ func (f *FlagSet) Int64VarP(p *int64, name, shorthand string, value int64, usage
// Int64Var defines an int64 flag with specified name, default value, and usage string.
// The argument p points to an int64 variable in which to store the value of the flag.
func Int64Var(p *int64, name string, value int64, usage string) {
commandLine.VarP(newInt64Value(value, p), name, "", usage)
CommandLine.VarP(newInt64Value(value, p), name, "", usage)
}

// Like Int64Var, but accepts a shorthand letter that can be used after a single dash.
func Int64VarP(p *int64, name, shorthand string, value int64, usage string) {
commandLine.VarP(newInt64Value(value, p), name, shorthand, usage)
CommandLine.VarP(newInt64Value(value, p), name, shorthand, usage)
}

// Int64 defines an int64 flag with specified name, default value, and usage string.
Expand All @@ -61,10 +61,10 @@ func (f *FlagSet) Int64P(name, shorthand string, value int64, usage string) *int
// Int64 defines an int64 flag with specified name, default value, and usage string.
// The return value is the address of an int64 variable that stores the value of the flag.
func Int64(name string, value int64, usage string) *int64 {
return commandLine.Int64P(name, "", value, usage)
return CommandLine.Int64P(name, "", value, usage)
}

// Like Int64, but accepts a shorthand letter that can be used after a single dash.
func Int64P(name, shorthand string, value int64, usage string) *int64 {
return commandLine.Int64P(name, shorthand, value, usage)
return CommandLine.Int64P(name, shorthand, value, usage)
}
Loading

0 comments on commit e101bb9

Please sign in to comment.