diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index c605e6dd6d7..86a8cc2d231 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -476,12 +476,11 @@ }, { "ImportPath": "github.com/spf13/cobra", - "Rev": "385fc87e4343efec233811d3d933509e8975d11a" + "Rev": "db0518444643a7b170abb78164bbeaf5a2bb816f" }, { "ImportPath": "github.com/spf13/pflag", - "Comment": "v0.0.1-81-g4869ec2", - "Rev": "4869ec2ae0628354eaac5bf88fccf9a7265ae475" + "Rev": "112aaa578dfdd0e913663b05153be974bd72497a" }, { "ImportPath": "github.com/stretchr/objx", diff --git a/Godeps/_workspace/src/github.com/spf13/cobra/bash_completions.go b/Godeps/_workspace/src/github.com/spf13/cobra/bash_completions.go index 3a421bc7e1a..82c4274a8e1 100644 --- a/Godeps/_workspace/src/github.com/spf13/cobra/bash_completions.go +++ b/Godeps/_workspace/src/github.com/spf13/cobra/bash_completions.go @@ -13,6 +13,7 @@ import ( const ( BashCompFilenameExt = "cobra_annotation_bash_completion_filename_extentions" BashCompOneRequiredFlag = "cobra_annotation_bash_completion_one_required_flag" + BashCompSubdirsInDir = "cobra_annotation_bash_completion_subdirs_in_dir" ) func preamble(out *bytes.Buffer) { @@ -100,6 +101,12 @@ __handle_filename_extension_flag() _filedir "@(${ext})" } +__handle_subdirs_in_dir_flag() +{ + local dir="$1" + pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 +} + __handle_flag() { __debug "${FUNCNAME}: c is $c words[c] is ${words[c]}" @@ -226,6 +233,16 @@ func writeFlagHandler(name string, annotations map[string][]string, out *bytes.B ext := "_filedir" fmt.Fprintf(out, " flags_completion+=(%q)\n", ext) } + case BashCompSubdirsInDir: + fmt.Fprintf(out, " flags_with_completion+=(%q)\n", name) + + if len(value) == 1 { + ext := "__handle_subdirs_in_dir_flag " + value[0] + fmt.Fprintf(out, " flags_completion+=(%q)\n", ext) + } else { + ext := "_filedir -d" + fmt.Fprintf(out, " flags_completion+=(%q)\n", ext) + } } } } diff --git a/Godeps/_workspace/src/github.com/spf13/cobra/bash_completions_test.go b/Godeps/_workspace/src/github.com/spf13/cobra/bash_completions_test.go index acb6d81bd7e..a1f2b13cb3c 100644 --- a/Godeps/_workspace/src/github.com/spf13/cobra/bash_completions_test.go +++ b/Godeps/_workspace/src/github.com/spf13/cobra/bash_completions_test.go @@ -56,6 +56,11 @@ func TestBashCompletions(t *testing.T) { c.Flags().StringVar(&flagvalExt, "filename-ext", "", "Enter a filename (extension limited)") c.MarkFlagFilename("filename-ext") + // subdirectories in a given directory + var flagvalTheme string + c.Flags().StringVar(&flagvalTheme, "theme", "", "theme to use (located in /themes/THEMENAME/)") + c.Flags().SetAnnotation("theme", BashCompSubdirsInDir, []string{"themes"}) + out := new(bytes.Buffer) c.GenBashCompletion(out) str := out.String() @@ -75,6 +80,8 @@ func TestBashCompletions(t *testing.T) { check(t, str, `flags_completion+=("_filedir")`) // check for filename extension flags check(t, str, `flags_completion+=("__handle_filename_extension_flag json|yaml|yml")`) + // check for subdirs_in_dir flags + check(t, str, `flags_completion+=("__handle_subdirs_in_dir_flag themes")`) checkOmit(t, str, cmdDeprecated.Name()) } diff --git a/Godeps/_workspace/src/github.com/spf13/cobra/cobra_test.go b/Godeps/_workspace/src/github.com/spf13/cobra/cobra_test.go index 7cb4917d818..4fc3b88b845 100644 --- a/Godeps/_workspace/src/github.com/spf13/cobra/cobra_test.go +++ b/Godeps/_workspace/src/github.com/spf13/cobra/cobra_test.go @@ -963,3 +963,11 @@ func TestGlobalNormFuncPropagation(t *testing.T) { t.Error("cmdPrint and cmdEchoSub should had the normalization function of rootCmd") } } + +func TestFlagOnPflagCommandLine(t *testing.T) { + flagName := "flagOnCommandLine" + pflag.CommandLine.String(flagName, "", "about my flag") + r := fullSetupTest("--help") + + checkResultContains(t, r, flagName) +} diff --git a/Godeps/_workspace/src/github.com/spf13/cobra/command.go b/Godeps/_workspace/src/github.com/spf13/cobra/command.go index 74565c2b7b3..cbbc3264f28 100644 --- a/Godeps/_workspace/src/github.com/spf13/cobra/command.go +++ b/Godeps/_workspace/src/github.com/spf13/cobra/command.go @@ -158,7 +158,6 @@ func (c *Command) SetHelpTemplate(s string) { func (c *Command) SetGlobalNormalizationFunc(n func(f *flag.FlagSet, name string) flag.NormalizedName) { c.Flags().SetNormalizeFunc(n) c.PersistentFlags().SetNormalizeFunc(n) - c.LocalFlags().SetNormalizeFunc(n) c.globNormFunc = n for _, command := range c.commands { @@ -873,6 +872,13 @@ func (c *Command) LocalFlags() *flag.FlagSet { c.lflags.VisitAll(func(f *flag.Flag) { local.AddFlag(f) }) + if !c.HasParent() { + flag.CommandLine.VisitAll(func(f *flag.Flag) { + if local.Lookup(f.Name) == nil { + local.AddFlag(f) + } + }) + } return local } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/bool.go b/Godeps/_workspace/src/github.com/spf13/pflag/bool.go index 04c9b5aff3d..d272e40bddc 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/bool.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/bool.go @@ -53,7 +53,7 @@ func (f *FlagSet) BoolVar(p *bool, name string, value bool, usage string) { f.BoolVarP(p, name, "", value, usage) } -// Like BoolVar, but accepts a shorthand letter that can be used after a single dash. +// BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) BoolVarP(p *bool, name, shorthand string, value bool, usage string) { flag := f.VarPF(newBoolValue(value, p), name, shorthand, usage) flag.NoOptDefVal = "true" @@ -65,7 +65,7 @@ func BoolVar(p *bool, name string, value bool, usage string) { BoolVarP(p, name, "", value, usage) } -// Like BoolVar, but accepts a shorthand letter that can be used after a single dash. +// BoolVarP is 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) { flag := CommandLine.VarPF(newBoolValue(value, p), name, shorthand, usage) flag.NoOptDefVal = "true" @@ -77,7 +77,7 @@ func (f *FlagSet) Bool(name string, value bool, usage string) *bool { return f.BoolP(name, "", value, usage) } -// Like Bool, but accepts a shorthand letter that can be used after a single dash. +// BoolP is like Bool, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) BoolP(name, shorthand string, value bool, usage string) *bool { p := new(bool) f.BoolVarP(p, name, shorthand, value, usage) @@ -90,7 +90,7 @@ func Bool(name string, value bool, usage string) *bool { return BoolP(name, "", value, usage) } -// Like Bool, but accepts a shorthand letter that can be used after a single dash. +// BoolP is 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 { b := CommandLine.BoolP(name, shorthand, value, usage) return b diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/count.go b/Godeps/_workspace/src/github.com/spf13/pflag/count.go index d0613688e5b..7b1f142e78a 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/count.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/count.go @@ -38,6 +38,7 @@ func countConv(sval string) (interface{}, error) { return i, nil } +// GetCount return the int value of a flag with the given name func (f *FlagSet) GetCount(name string) (int, error) { val, err := f.getFlagType(name, "count", countConv) if err != nil { @@ -46,39 +47,51 @@ func (f *FlagSet) GetCount(name string) (int, error) { return val.(int), nil } +// CountVar defines a count 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. +// A count flag will add 1 to its value evey time it is found on the command line func (f *FlagSet) CountVar(p *int, name string, usage string) { f.CountVarP(p, name, "", usage) } +// CountVarP is like CountVar only take a shorthand for the flag name. func (f *FlagSet) CountVarP(p *int, name, shorthand string, usage string) { flag := f.VarPF(newCountValue(0, p), name, shorthand, usage) flag.NoOptDefVal = "-1" } +// CountVar like CountVar only the flag is placed on the CommandLine instead of a given flag set func CountVar(p *int, name string, usage string) { CommandLine.CountVar(p, name, usage) } +// CountVarP is like CountVar only take a shorthand for the flag name. func CountVarP(p *int, name, shorthand string, usage string) { CommandLine.CountVarP(p, name, shorthand, usage) } +// Count defines a count 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. +// A count flag will add 1 to its value evey time it is found on the command line func (f *FlagSet) Count(name string, usage string) *int { p := new(int) f.CountVarP(p, name, "", usage) return p } +// CountP is like Count only takes a shorthand for the flag name. func (f *FlagSet) CountP(name, shorthand string, usage string) *int { p := new(int) f.CountVarP(p, name, shorthand, usage) return p } +// Count like Count only the flag is placed on the CommandLine isntead of a given flag set func Count(name string, usage string) *int { return CommandLine.CountP(name, "", usage) } +// CountP is like Count only takes a shorthand for the flag name. func CountP(name, shorthand string, usage string) *int { return CommandLine.CountP(name, shorthand, usage) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/duration.go b/Godeps/_workspace/src/github.com/spf13/pflag/duration.go index 382ffd3c5e2..e9debef88ee 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/duration.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/duration.go @@ -43,7 +43,7 @@ func (f *FlagSet) DurationVar(p *time.Duration, name string, value time.Duration f.VarP(newDurationValue(value, p), name, "", usage) } -// Like DurationVar, but accepts a shorthand letter that can be used after a single dash. +// DurationVarP is like DurationVar, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string) { f.VarP(newDurationValue(value, p), name, shorthand, usage) } @@ -54,7 +54,7 @@ func DurationVar(p *time.Duration, name string, value time.Duration, usage strin CommandLine.VarP(newDurationValue(value, p), name, "", usage) } -// Like DurationVar, but accepts a shorthand letter that can be used after a single dash. +// DurationVarP is 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) } @@ -67,7 +67,7 @@ func (f *FlagSet) Duration(name string, value time.Duration, usage string) *time return p } -// Like Duration, but accepts a shorthand letter that can be used after a single dash. +// DurationP is like Duration, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration { p := new(time.Duration) f.DurationVarP(p, name, shorthand, value, usage) @@ -80,7 +80,7 @@ func Duration(name string, value time.Duration, usage string) *time.Duration { return CommandLine.DurationP(name, "", value, usage) } -// Like Duration, but accepts a shorthand letter that can be used after a single dash. +// DurationP is 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) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/flag.go b/Godeps/_workspace/src/github.com/spf13/pflag/flag.go index c45ad0f0e33..603c81aaf0f 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/flag.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/flag.go @@ -3,98 +3,98 @@ // license that can be found in the LICENSE file. /* - pflag is a drop-in replacement for Go's flag package, implementing - POSIX/GNU-style --flags. +Package pflag is a drop-in replacement for Go's flag package, implementing +POSIX/GNU-style --flags. - pflag is compatible with the GNU extensions to the POSIX recommendations - for command-line options. See - http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html +pflag is compatible with the GNU extensions to the POSIX recommendations +for command-line options. See +http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html - Usage: +Usage: - pflag is a drop-in replacement of Go's native flag package. If you import - pflag under the name "flag" then all code should continue to function - with no changes. +pflag is a drop-in replacement of Go's native flag package. If you import +pflag under the name "flag" then all code should continue to function +with no changes. - import flag "github.com/ogier/pflag" + import flag "github.com/ogier/pflag" There is one exception to this: if you directly instantiate the Flag struct - there is one more field "Shorthand" that you will need to set. - Most code never instantiates this struct directly, and instead uses - functions such as String(), BoolVar(), and Var(), and is therefore - unaffected. +there is one more field "Shorthand" that you will need to set. +Most code never instantiates this struct directly, and instead uses +functions such as String(), BoolVar(), and Var(), and is therefore +unaffected. - Define flags using flag.String(), Bool(), Int(), etc. +Define flags using flag.String(), Bool(), Int(), etc. - This declares an integer flag, -flagname, stored in the pointer ip, with type *int. - var ip = flag.Int("flagname", 1234, "help message for flagname") - If you like, you can bind the flag to a variable using the Var() functions. - var flagvar int - func init() { - flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") - } - Or you can create custom flags that satisfy the Value interface (with - pointer receivers) and couple them to flag parsing by - flag.Var(&flagVal, "name", "help message for flagname") - For such flags, the default value is just the initial value of the variable. +This declares an integer flag, -flagname, stored in the pointer ip, with type *int. + var ip = flag.Int("flagname", 1234, "help message for flagname") +If you like, you can bind the flag to a variable using the Var() functions. + var flagvar int + func init() { + flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") + } +Or you can create custom flags that satisfy the Value interface (with +pointer receivers) and couple them to flag parsing by + flag.Var(&flagVal, "name", "help message for flagname") +For such flags, the default value is just the initial value of the variable. - After all flags are defined, call - flag.Parse() - to parse the command line into the defined flags. +After all flags are defined, call + flag.Parse() +to parse the command line into the defined flags. - Flags may then be used directly. If you're using the flags themselves, - they are all pointers; if you bind to variables, they're values. - fmt.Println("ip has value ", *ip) - fmt.Println("flagvar has value ", flagvar) +Flags may then be used directly. If you're using the flags themselves, +they are all pointers; if you bind to variables, they're values. + fmt.Println("ip has value ", *ip) + fmt.Println("flagvar has value ", flagvar) - After parsing, the arguments after the flag are available as the - slice flag.Args() or individually as flag.Arg(i). - The arguments are indexed from 0 through flag.NArg()-1. +After parsing, the arguments after the flag are available as the +slice flag.Args() or individually as flag.Arg(i). +The arguments are indexed from 0 through flag.NArg()-1. - The pflag package also defines some new functions that are not in flag, - that give one-letter shorthands for flags. You can use these by appending - 'P' to the name of any function that defines a flag. - var ip = flag.IntP("flagname", "f", 1234, "help message") - var flagvar bool - func init() { - flag.BoolVarP("boolname", "b", true, "help message") - } - flag.VarP(&flagVar, "varname", "v", 1234, "help message") - Shorthand letters can be used with single dashes on the command line. - Boolean shorthand flags can be combined with other shorthand flags. +The pflag package also defines some new functions that are not in flag, +that give one-letter shorthands for flags. You can use these by appending +'P' to the name of any function that defines a flag. + var ip = flag.IntP("flagname", "f", 1234, "help message") + var flagvar bool + func init() { + flag.BoolVarP("boolname", "b", true, "help message") + } + flag.VarP(&flagVar, "varname", "v", 1234, "help message") +Shorthand letters can be used with single dashes on the command line. +Boolean shorthand flags can be combined with other shorthand flags. - Command line flag syntax: - --flag // boolean flags only - --flag=x +Command line flag syntax: + --flag // boolean flags only + --flag=x - Unlike the flag package, a single dash before an option means something - different than a double dash. Single dashes signify a series of shorthand - letters for flags. All but the last shorthand letter must be boolean flags. - // boolean flags - -f - -abc - // non-boolean flags - -n 1234 - -Ifile - // mixed - -abcs "hello" - -abcn1234 +Unlike the flag package, a single dash before an option means something +different than a double dash. Single dashes signify a series of shorthand +letters for flags. All but the last shorthand letter must be boolean flags. + // boolean flags + -f + -abc + // non-boolean flags + -n 1234 + -Ifile + // mixed + -abcs "hello" + -abcn1234 - Flag parsing stops after the terminator "--". Unlike the flag package, - flags can be interspersed with arguments anywhere on the command line - before this terminator. +Flag parsing stops after the terminator "--". Unlike the flag package, +flags can be interspersed with arguments anywhere on the command line +before this terminator. - Integer flags accept 1234, 0664, 0x1234 and may be negative. - Boolean flags (in their long form) accept 1, 0, t, f, true, false, - TRUE, FALSE, True, False. - Duration flags accept any input valid for time.ParseDuration. +Integer flags accept 1234, 0664, 0x1234 and may be negative. +Boolean flags (in their long form) accept 1, 0, t, f, true, false, +TRUE, FALSE, True, False. +Duration flags accept any input valid for time.ParseDuration. - The default set of command-line flags is controlled by - top-level functions. The FlagSet type allows one to define - independent sets of flags, such as to implement subcommands - in a command-line interface. The methods of FlagSet are - analogous to the top-level functions for the command-line - flag set. +The default set of command-line flags is controlled by +top-level functions. The FlagSet type allows one to define +independent sets of flags, such as to implement subcommands +in a command-line interface. The methods of FlagSet are +analogous to the top-level functions for the command-line +flag set. */ package pflag @@ -115,8 +115,11 @@ var ErrHelp = errors.New("pflag: help requested") type ErrorHandling int const ( + // ContinueOnError will return an err from Parse() if an error is found ContinueOnError ErrorHandling = iota + // ExitOnError will call os.Exit(2) if an error is found when parsing ExitOnError + // PanicOnError will panic() if an error is found when parsing flags PanicOnError ) @@ -181,6 +184,11 @@ func sortFlags(flags map[NormalizedName]*Flag) []*Flag { return result } +// SetNormalizeFunc allows you to add a function which can translate flag names. +// Flags added to the FlagSet will be translated and then when anything tries to +// look up the flag that will also be translated. So it would be possible to create +// a flag named "getURL" and have it translated to "geturl". A user could then pass +// "--getUrl" which may also be translated to "geturl" and everything will work. func (f *FlagSet) SetNormalizeFunc(n func(f *FlagSet, name string) NormalizedName) { f.normalizeNameFunc = n for k, v := range f.formal { @@ -191,6 +199,8 @@ func (f *FlagSet) SetNormalizeFunc(n func(f *FlagSet, name string) NormalizedNam } } +// GetNormalizeFunc returns the previously set NormalizeFunc of a function which +// does no translation, if not set previously. func (f *FlagSet) GetNormalizeFunc() func(f *FlagSet, name string) NormalizedName { if f.normalizeNameFunc != nil { return f.normalizeNameFunc @@ -224,6 +234,7 @@ func (f *FlagSet) VisitAll(fn func(*Flag)) { } } +// HasFlags returns a bool to indicate if the FlagSet has any flags definied. func (f *FlagSet) HasFlags() bool { return len(f.formal) > 0 } @@ -279,7 +290,9 @@ func (f *FlagSet) getFlagType(name string, ftype string, convFunc func(sval stri return result, nil } -// Mark a flag deprecated in your program +// MarkDeprecated indicated that a flag is deprecated in your program. It will +// continue to function but will not show up in help or usage messages. Using +// this flag will also print the given usageMessage. func (f *FlagSet) MarkDeprecated(name string, usageMessage string) error { flag := f.Lookup(name) if flag == nil { @@ -317,6 +330,9 @@ func (f *FlagSet) Set(name, value string) error { return nil } +// SetAnnotation allows one to set arbitrary annotations on a flag in the FlagSet. +// This is sometimes used by spf13/cobra programs which want to generate additional +// bash completion information. func (f *FlagSet) SetAnnotation(name, key string, values []string) error { normalName := f.normalizeFlagName(name) flag, ok := f.formal[normalName] @@ -330,6 +346,8 @@ func (f *FlagSet) SetAnnotation(name, key string, values []string) error { return nil } +// Changed returns true if the flag was explicitly set during Parse() and false +// otherwise func (f *FlagSet) Changed(name string) bool { flag := f.Lookup(name) // If a flag doesn't exist, it wasn't changed.... @@ -347,12 +365,20 @@ func Set(name, value string) error { // PrintDefaults prints, to standard error unless configured // otherwise, the default values of all defined flags in the set. func (f *FlagSet) PrintDefaults() { + usages := f.FlagUsages() + fmt.Fprintf(f.out(), "%s", usages) +} + +// FlagUsages Returns a string containing the usage information for all flags in +// the FlagSet +func (f *FlagSet) FlagUsages() string { + x := new(bytes.Buffer) + f.VisitAll(func(flag *Flag) { if len(flag.Deprecated) > 0 { return } format := "" - // ex: w/ option string argument '-%s, --%s[=%q]: %s\n' if len(flag.Shorthand) > 0 { format = " -%s, --%s" } else { @@ -361,7 +387,8 @@ func (f *FlagSet) PrintDefaults() { if len(flag.NoOptDefVal) > 0 { format = format + "[" } - if _, ok := flag.Value.(*stringValue); ok { + if flag.Value.Type() == "string" { + // put quotes on the value format = format + "=%q" } else { format = format + "=%s" @@ -370,27 +397,6 @@ func (f *FlagSet) PrintDefaults() { format = format + "]" } format = format + ": %s\n" - fmt.Fprintf(f.out(), format, flag.Shorthand, flag.Name, flag.DefValue, flag.Usage) - }) -} - -func (f *FlagSet) FlagUsages() string { - x := new(bytes.Buffer) - - f.VisitAll(func(flag *Flag) { - if len(flag.Deprecated) > 0 { - return - } - format := "--%s=%s: %s\n" - if _, ok := flag.Value.(*stringValue); ok { - // put quotes on the value - format = "--%s=%q: %s\n" - } - if len(flag.Shorthand) > 0 { - format = " -%s, " + format - } else { - format = " %s " + format - } fmt.Fprintf(x, format, flag.Shorthand, flag.Name, flag.DefValue, flag.Usage) }) @@ -462,7 +468,7 @@ func (f *FlagSet) Var(value Value, name string, usage string) { f.VarP(value, name, "", usage) } -// Like VarP, but returns the flag created +// VarPF is like VarP, but returns the flag created func (f *FlagSet) VarPF(value Value, name, shorthand, usage string) *Flag { // Remember the default value as a string; it won't change. flag := &Flag{ @@ -476,14 +482,15 @@ func (f *FlagSet) VarPF(value Value, name, shorthand, usage string) *Flag { return flag } -// Like Var, but accepts a shorthand letter that can be used after a single dash. +// VarP is like Var, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) VarP(value Value, name, shorthand, usage string) { _ = f.VarPF(value, name, shorthand, usage) } +// AddFlag will add the flag to the FlagSet func (f *FlagSet) AddFlag(flag *Flag) { // Call normalizeFlagName function only once - var normalizedFlagName NormalizedName = f.normalizeFlagName(flag.Name) + normalizedFlagName := f.normalizeFlagName(flag.Name) _, alreadythere := f.formal[normalizedFlagName] if alreadythere { @@ -517,6 +524,19 @@ func (f *FlagSet) AddFlag(flag *Flag) { f.shorthands[c] = flag } +// AddFlagSet adds one FlagSet to another. If a flag is already present in f +// the flag from newSet will be ignored +func (f *FlagSet) AddFlagSet(newSet *FlagSet) { + if newSet == nil { + return + } + newSet.VisitAll(func(flag *Flag) { + if f.Lookup(flag.Name) == nil { + f.AddFlag(flag) + } + }) +} + // 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 // typically holds a user-defined implementation of Value. For instance, the @@ -527,7 +547,7 @@ func Var(value Value, name string, usage string) { CommandLine.VarP(value, name, "", usage) } -// Like Var, but accepts a shorthand letter that can be used after a single dash. +// VarP is 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) } @@ -720,7 +740,7 @@ func Parse() { CommandLine.Parse(os.Args[1:]) } -// Whether to support interspersed option/non-option arguments. +// SetInterspersed sets whether to support interspersed option/non-option arguments. func SetInterspersed(interspersed bool) { CommandLine.SetInterspersed(interspersed) } @@ -744,7 +764,7 @@ func NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet { return f } -// Whether to support interspersed option/non-option arguments. +// SetIntersperesed sets whether to support interspersed option/non-option arguments. func (f *FlagSet) SetInterspersed(interspersed bool) { f.interspersed = interspersed } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/flag_test.go b/Godeps/_workspace/src/github.com/spf13/pflag/flag_test.go index e654553c35f..5114f28d3bf 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/flag_test.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/flag_test.go @@ -19,15 +19,15 @@ import ( ) var ( - test_bool = Bool("test_bool", false, "bool value") - test_int = Int("test_int", 0, "int value") - test_int64 = Int64("test_int64", 0, "int64 value") - test_uint = Uint("test_uint", 0, "uint value") - test_uint64 = Uint64("test_uint64", 0, "uint64 value") - test_string = String("test_string", "0", "string value") - test_float64 = Float64("test_float64", 0, "float64 value") - test_duration = Duration("test_duration", 0, "time.Duration value") - test_optional_int = Int("test_optional_int", 0, "optional int value") + testBool = Bool("test_bool", false, "bool value") + testInt = Int("test_int", 0, "int value") + testInt64 = Int64("test_int64", 0, "int64 value") + testUint = Uint("test_uint", 0, "uint value") + testUint64 = Uint64("test_uint64", 0, "uint64 value") + testString = String("test_string", "0", "string value") + testFloat = Float64("test_float64", 0, "float64 value") + testDuration = Duration("test_duration", 0, "time.Duration value") + testOptionalInt = Int("test_optional_int", 0, "optional int value") normalizeFlagNameInvocations = 0 ) @@ -110,6 +110,23 @@ func TestUsage(t *testing.T) { } } +func TestAddFlagSet(t *testing.T) { + oldSet := NewFlagSet("old", ContinueOnError) + newSet := NewFlagSet("new", ContinueOnError) + + oldSet.String("flag1", "flag1", "flag1") + oldSet.String("flag2", "flag2", "flag2") + + newSet.String("flag2", "flag2", "flag2") + newSet.String("flag3", "flag3", "flag3") + + oldSet.AddFlagSet(newSet) + + if len(oldSet.formal) != 3 { + t.Errorf("Unexpected result adding a FlagSet to a FlagSet %v", oldSet) + } +} + func TestAnnotation(t *testing.T) { f := NewFlagSet("shorthand", ContinueOnError) @@ -291,7 +308,7 @@ func testParse(f *FlagSet, t *testing.T) { t.Error("mask flag should be 255.255.255.0, is ", (*maskFlag).String()) } if v, err := f.GetIPv4Mask("mask"); err != nil || v.String() != (*maskFlag).String() { - t.Errorf("GetIP returned %v but maskFlag was %v", v, *maskFlag, err) + t.Errorf("GetIP returned %v maskFlag was %v error was %v", v, *maskFlag, err) } if *durationFlag != 2*time.Minute { t.Error("duration flag should be 2m, is ", *durationFlag) diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/float32.go b/Godeps/_workspace/src/github.com/spf13/pflag/float32.go index 30174cb27fa..7683fae1b14 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/float32.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/float32.go @@ -48,7 +48,7 @@ func (f *FlagSet) Float32Var(p *float32, name string, value float32, usage strin f.VarP(newFloat32Value(value, p), name, "", usage) } -// Like Float32Var, but accepts a shorthand letter that can be used after a single dash. +// Float32VarP is like Float32Var, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Float32VarP(p *float32, name, shorthand string, value float32, usage string) { f.VarP(newFloat32Value(value, p), name, shorthand, usage) } @@ -59,7 +59,7 @@ func Float32Var(p *float32, name string, value float32, usage string) { CommandLine.VarP(newFloat32Value(value, p), name, "", usage) } -// Like Float32Var, but accepts a shorthand letter that can be used after a single dash. +// Float32VarP is 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) } @@ -72,7 +72,7 @@ func (f *FlagSet) Float32(name string, value float32, usage string) *float32 { return p } -// Like Float32, but accepts a shorthand letter that can be used after a single dash. +// Float32P is like Float32, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Float32P(name, shorthand string, value float32, usage string) *float32 { p := new(float32) f.Float32VarP(p, name, shorthand, value, usage) @@ -85,7 +85,7 @@ func Float32(name string, value float32, usage string) *float32 { return CommandLine.Float32P(name, "", value, usage) } -// Like Float32, but accepts a shorthand letter that can be used after a single dash. +// Float32P is 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) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/float64.go b/Godeps/_workspace/src/github.com/spf13/pflag/float64.go index 10e17e4bae8..50fbf8cc1a1 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/float64.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/float64.go @@ -44,7 +44,7 @@ func (f *FlagSet) Float64Var(p *float64, name string, value float64, usage strin f.VarP(newFloat64Value(value, p), name, "", usage) } -// Like Float64Var, but accepts a shorthand letter that can be used after a single dash. +// Float64VarP is like Float64Var, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Float64VarP(p *float64, name, shorthand string, value float64, usage string) { f.VarP(newFloat64Value(value, p), name, shorthand, usage) } @@ -55,7 +55,7 @@ func Float64Var(p *float64, name string, value float64, usage string) { CommandLine.VarP(newFloat64Value(value, p), name, "", usage) } -// Like Float64Var, but accepts a shorthand letter that can be used after a single dash. +// Float64VarP is 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) } @@ -68,7 +68,7 @@ func (f *FlagSet) Float64(name string, value float64, usage string) *float64 { return p } -// Like Float64, but accepts a shorthand letter that can be used after a single dash. +// Float64P is like Float64, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Float64P(name, shorthand string, value float64, usage string) *float64 { p := new(float64) f.Float64VarP(p, name, shorthand, value, usage) @@ -81,7 +81,7 @@ func Float64(name string, value float64, usage string) *float64 { return CommandLine.Float64P(name, "", value, usage) } -// Like Float64, but accepts a shorthand letter that can be used after a single dash. +// Float64P is 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) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/golangflag.go b/Godeps/_workspace/src/github.com/spf13/pflag/golangflag.go new file mode 100644 index 00000000000..5213dc30609 --- /dev/null +++ b/Godeps/_workspace/src/github.com/spf13/pflag/golangflag.go @@ -0,0 +1,94 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package pflag + +import ( + goflag "flag" + "fmt" + "reflect" + "strings" +) + +var _ = fmt.Print + +// flagValueWrapper implements pflag.Value around a flag.Value. The main +// difference here is the addition of the Type method that returns a string +// name of the type. As this is generally unknown, we approximate that with +// reflection. +type flagValueWrapper struct { + inner goflag.Value + flagType string +} + +// We are just copying the boolFlag interface out of goflag as that is what +// they use to decide if a flag should get "true" when no arg is given. +type goBoolFlag interface { + goflag.Value + IsBoolFlag() bool +} + +func wrapFlagValue(v goflag.Value) Value { + // If the flag.Value happens to also be a pflag.Value, just use it directly. + if pv, ok := v.(Value); ok { + return pv + } + + pv := &flagValueWrapper{ + inner: v, + } + + t := reflect.TypeOf(v) + if t.Kind() == reflect.Interface || t.Kind() == reflect.Ptr { + t = t.Elem() + } + + pv.flagType = strings.TrimSuffix(t.Name(), "Value") + return pv +} + +func (v *flagValueWrapper) String() string { + return v.inner.String() +} + +func (v *flagValueWrapper) Set(s string) error { + return v.inner.Set(s) +} + +func (v *flagValueWrapper) Type() string { + return v.flagType +} + +func PFlagFromGoFlag(goflag *goflag.Flag) *Flag { + // Remember the default value as a string; it won't change. + flag := &Flag{ + Name: goflag.Name, + Usage: goflag.Usage, + Value: wrapFlagValue(goflag.Value), + // Looks like golang flags don't set DefValue correctly :-( + //DefValue: goflag.DefValue, + DefValue: goflag.Value.String(), + } + if fv, ok := goflag.Value.(goBoolFlag); ok && fv.IsBoolFlag() { + flag.NoOptDefVal = "true" + } + return flag +} + +func (f *FlagSet) AddGoFlag(goflag *goflag.Flag) { + if f.Lookup(goflag.Name) != nil { + return + } + newflag := PFlagFromGoFlag(goflag) + f.AddFlag(newflag) +} + +func (f *FlagSet) AddGoFlagSet(newSet *goflag.FlagSet) { + if newSet == nil { + return + } + newSet.VisitAll(func(goflag *goflag.Flag) { + f.AddGoFlag(goflag) + }) +} diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/golangflag_test.go b/Godeps/_workspace/src/github.com/spf13/pflag/golangflag_test.go new file mode 100644 index 00000000000..77e2d7d80a3 --- /dev/null +++ b/Godeps/_workspace/src/github.com/spf13/pflag/golangflag_test.go @@ -0,0 +1,39 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package pflag + +import ( + goflag "flag" + "testing" +) + +func TestGoflags(t *testing.T) { + goflag.String("stringFlag", "stringFlag", "stringFlag") + goflag.Bool("boolFlag", false, "boolFlag") + + f := NewFlagSet("test", ContinueOnError) + + f.AddGoFlagSet(goflag.CommandLine) + err := f.Parse([]string{"--stringFlag=bob", "--boolFlag"}) + if err != nil { + t.Fatal("expected no error; get", err) + } + + getString, err := f.GetString("stringFlag") + if err != nil { + t.Fatal("expected no error; get", err) + } + if getString != "bob" { + t.Fatalf("expected getString=bob but got getString=%s", getString) + } + + getBool, err := f.GetBool("boolFlag") + if err != nil { + t.Fatal("expected no error; get", err) + } + if getBool != true { + t.Fatalf("expected getBool=true but got getBool=%v", getBool) + } +} diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/int.go b/Godeps/_workspace/src/github.com/spf13/pflag/int.go index 23f70dddb19..b6560368a91 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/int.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/int.go @@ -44,7 +44,7 @@ func (f *FlagSet) IntVar(p *int, name string, value int, usage string) { f.VarP(newIntValue(value, p), name, "", usage) } -// Like IntVar, but accepts a shorthand letter that can be used after a single dash. +// IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) IntVarP(p *int, name, shorthand string, value int, usage string) { f.VarP(newIntValue(value, p), name, shorthand, usage) } @@ -55,7 +55,7 @@ func IntVar(p *int, name string, value int, usage string) { CommandLine.VarP(newIntValue(value, p), name, "", usage) } -// Like IntVar, but accepts a shorthand letter that can be used after a single dash. +// IntVarP is 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) } @@ -68,7 +68,7 @@ func (f *FlagSet) Int(name string, value int, usage string) *int { return p } -// Like Int, but accepts a shorthand letter that can be used after a single dash. +// IntP is like Int, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) IntP(name, shorthand string, value int, usage string) *int { p := new(int) f.IntVarP(p, name, shorthand, value, usage) @@ -81,7 +81,7 @@ func Int(name string, value int, usage string) *int { return CommandLine.IntP(name, "", value, usage) } -// Like Int, but accepts a shorthand letter that can be used after a single dash. +// IntP is 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) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/int32.go b/Godeps/_workspace/src/github.com/spf13/pflag/int32.go index 515f90bb7b9..41659a9aff3 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/int32.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/int32.go @@ -48,7 +48,7 @@ func (f *FlagSet) Int32Var(p *int32, name string, value int32, usage string) { f.VarP(newInt32Value(value, p), name, "", usage) } -// Like Int32Var, but accepts a shorthand letter that can be used after a single dash. +// Int32VarP is like Int32Var, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Int32VarP(p *int32, name, shorthand string, value int32, usage string) { f.VarP(newInt32Value(value, p), name, shorthand, usage) } @@ -59,7 +59,7 @@ func Int32Var(p *int32, name string, value int32, usage string) { CommandLine.VarP(newInt32Value(value, p), name, "", usage) } -// Like Int32Var, but accepts a shorthand letter that can be used after a single dash. +// Int32VarP is 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) } @@ -72,7 +72,7 @@ func (f *FlagSet) Int32(name string, value int32, usage string) *int32 { return p } -// Like Int32, but accepts a shorthand letter that can be used after a single dash. +// Int32P is like Int32, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Int32P(name, shorthand string, value int32, usage string) *int32 { p := new(int32) f.Int32VarP(p, name, shorthand, value, usage) @@ -85,7 +85,7 @@ func Int32(name string, value int32, usage string) *int32 { return CommandLine.Int32P(name, "", value, usage) } -// Like Int32, but accepts a shorthand letter that can be used after a single dash. +// Int32P is 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) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/int64.go b/Godeps/_workspace/src/github.com/spf13/pflag/int64.go index b77ade41398..6e67e380f46 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/int64.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/int64.go @@ -44,7 +44,7 @@ func (f *FlagSet) Int64Var(p *int64, name string, value int64, usage string) { f.VarP(newInt64Value(value, p), name, "", usage) } -// Like Int64Var, but accepts a shorthand letter that can be used after a single dash. +// Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Int64VarP(p *int64, name, shorthand string, value int64, usage string) { f.VarP(newInt64Value(value, p), name, shorthand, usage) } @@ -55,7 +55,7 @@ func Int64Var(p *int64, name string, value int64, usage string) { CommandLine.VarP(newInt64Value(value, p), name, "", usage) } -// Like Int64Var, but accepts a shorthand letter that can be used after a single dash. +// Int64VarP is 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) } @@ -68,7 +68,7 @@ func (f *FlagSet) Int64(name string, value int64, usage string) *int64 { return p } -// Like Int64, but accepts a shorthand letter that can be used after a single dash. +// Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Int64P(name, shorthand string, value int64, usage string) *int64 { p := new(int64) f.Int64VarP(p, name, shorthand, value, usage) @@ -81,7 +81,7 @@ func Int64(name string, value int64, usage string) *int64 { return CommandLine.Int64P(name, "", value, usage) } -// Like Int64, but accepts a shorthand letter that can be used after a single dash. +// Int64P is 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) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/int8.go b/Godeps/_workspace/src/github.com/spf13/pflag/int8.go index c51cb4fff33..400db21f5e9 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/int8.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/int8.go @@ -48,7 +48,7 @@ func (f *FlagSet) Int8Var(p *int8, name string, value int8, usage string) { f.VarP(newInt8Value(value, p), name, "", usage) } -// Like Int8Var, but accepts a shorthand letter that can be used after a single dash. +// Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Int8VarP(p *int8, name, shorthand string, value int8, usage string) { f.VarP(newInt8Value(value, p), name, shorthand, usage) } @@ -59,7 +59,7 @@ func Int8Var(p *int8, name string, value int8, usage string) { CommandLine.VarP(newInt8Value(value, p), name, "", usage) } -// Like Int8Var, but accepts a shorthand letter that can be used after a single dash. +// Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash. func Int8VarP(p *int8, name, shorthand string, value int8, usage string) { CommandLine.VarP(newInt8Value(value, p), name, shorthand, usage) } @@ -72,7 +72,7 @@ func (f *FlagSet) Int8(name string, value int8, usage string) *int8 { return p } -// Like Int8, but accepts a shorthand letter that can be used after a single dash. +// Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Int8P(name, shorthand string, value int8, usage string) *int8 { p := new(int8) f.Int8VarP(p, name, shorthand, value, usage) @@ -85,7 +85,7 @@ func Int8(name string, value int8, usage string) *int8 { return CommandLine.Int8P(name, "", value, usage) } -// Like Int8, but accepts a shorthand letter that can be used after a single dash. +// Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash. func Int8P(name, shorthand string, value int8, usage string) *int8 { return CommandLine.Int8P(name, shorthand, value, usage) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/int_slice.go b/Godeps/_workspace/src/github.com/spf13/pflag/int_slice.go index 7c6ed79f26d..1e7c9edde95 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/int_slice.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/int_slice.go @@ -85,7 +85,7 @@ func (f *FlagSet) IntSliceVar(p *[]int, name string, value []int, usage string) f.VarP(newIntSliceValue(value, p), name, "", usage) } -// Like IntSliceVar, but accepts a shorthand letter that can be used after a single dash. +// IntSliceVarP is like IntSliceVar, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) IntSliceVarP(p *[]int, name, shorthand string, value []int, usage string) { f.VarP(newIntSliceValue(value, p), name, shorthand, usage) } @@ -96,7 +96,7 @@ func IntSliceVar(p *[]int, name string, value []int, usage string) { CommandLine.VarP(newIntSliceValue(value, p), name, "", usage) } -// Like IntSliceVar, but accepts a shorthand letter that can be used after a single dash. +// IntSliceVarP is like IntSliceVar, but accepts a shorthand letter that can be used after a single dash. func IntSliceVarP(p *[]int, name, shorthand string, value []int, usage string) { CommandLine.VarP(newIntSliceValue(value, p), name, shorthand, usage) } @@ -104,14 +104,14 @@ func IntSliceVarP(p *[]int, name, shorthand string, value []int, usage string) { // IntSlice defines a []int flag with specified name, default value, and usage string. // The return value is the address of a []int variable that stores the value of the flag. func (f *FlagSet) IntSlice(name string, value []int, usage string) *[]int { - p := make([]int, 0) + p := []int{} f.IntSliceVarP(&p, name, "", value, usage) return &p } -// Like IntSlice, but accepts a shorthand letter that can be used after a single dash. +// IntSliceP is like IntSlice, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) IntSliceP(name, shorthand string, value []int, usage string) *[]int { - p := make([]int, 0) + p := []int{} f.IntSliceVarP(&p, name, shorthand, value, usage) return &p } @@ -122,7 +122,7 @@ func IntSlice(name string, value []int, usage string) *[]int { return CommandLine.IntSliceP(name, "", value, usage) } -// Like IntSlice, but accepts a shorthand letter that can be used after a single dash. +// IntSliceP is like IntSlice, but accepts a shorthand letter that can be used after a single dash. func IntSliceP(name, shorthand string, value []int, usage string) *[]int { return CommandLine.IntSliceP(name, shorthand, value, usage) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/int_slice_test.go b/Godeps/_workspace/src/github.com/spf13/pflag/int_slice_test.go index 2b7f68da93c..5f2eee66a43 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/int_slice_test.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/int_slice_test.go @@ -13,13 +13,13 @@ import ( func setUpISFlagSet(isp *[]int) *FlagSet { f := NewFlagSet("test", ContinueOnError) - f.IntSliceVar(isp, "is", []int{}, "Command seperated list!") + f.IntSliceVar(isp, "is", []int{}, "Command separated list!") return f } func setUpISFlagSetWithDefault(isp *[]int) *FlagSet { f := NewFlagSet("test", ContinueOnError) - f.IntSliceVar(isp, "is", []int{0, 1}, "Command seperated list!") + f.IntSliceVar(isp, "is", []int{0, 1}, "Command separated list!") return f } @@ -87,7 +87,7 @@ func TestISDefault(t *testing.T) { t.Fatalf("got error: %v", err) } if d != v { - t.Fatalf("expected is[%d] to be %s but got: %s", i, d, v) + t.Fatalf("expected is[%d] to be %d but got: %d", i, d, v) } } @@ -101,7 +101,7 @@ func TestISDefault(t *testing.T) { t.Fatal("got an error from GetIntSlice():", err) } if d != v { - t.Fatalf("expected is[%d] to be %s from GetIntSlice but got: %s", i, d, v) + t.Fatalf("expected is[%d] to be %d from GetIntSlice but got: %d", i, d, v) } } } @@ -122,7 +122,7 @@ func TestISWithDefault(t *testing.T) { t.Fatalf("got error: %v", err) } if d != v { - t.Fatalf("expected is[%d] to be %s but got: %s", i, d, v) + t.Fatalf("expected is[%d] to be %d but got: %d", i, d, v) } } @@ -136,7 +136,7 @@ func TestISWithDefault(t *testing.T) { t.Fatalf("got error: %v", err) } if d != v { - t.Fatalf("expected is[%d] to be %s from GetIntSlice but got: %s", i, d, v) + t.Fatalf("expected is[%d] to be %d from GetIntSlice but got: %d", i, d, v) } } } @@ -156,7 +156,7 @@ func TestISCalledTwice(t *testing.T) { } for i, v := range is { if expected[i] != v { - t.Fatalf("expected is[%d] to be %s but got: %s", i, expected[i], v) + t.Fatalf("expected is[%d] to be %d but got: %d", i, expected[i], v) } } } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/ip.go b/Godeps/_workspace/src/github.com/spf13/pflag/ip.go index baa442b5664..88a17430a09 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/ip.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/ip.go @@ -53,7 +53,7 @@ func (f *FlagSet) IPVar(p *net.IP, name string, value net.IP, usage string) { f.VarP(newIPValue(value, p), name, "", usage) } -// Like IPVar, but accepts a shorthand letter that can be used after a single dash. +// IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) { f.VarP(newIPValue(value, p), name, shorthand, usage) } @@ -64,7 +64,7 @@ func IPVar(p *net.IP, name string, value net.IP, usage string) { CommandLine.VarP(newIPValue(value, p), name, "", usage) } -// Like IPVar, but accepts a shorthand letter that can be used after a single dash. +// IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash. func IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) { CommandLine.VarP(newIPValue(value, p), name, shorthand, usage) } @@ -77,7 +77,7 @@ func (f *FlagSet) IP(name string, value net.IP, usage string) *net.IP { return p } -// Like IP, but accepts a shorthand letter that can be used after a single dash. +// IPP is like IP, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) IPP(name, shorthand string, value net.IP, usage string) *net.IP { p := new(net.IP) f.IPVarP(p, name, shorthand, value, usage) @@ -90,7 +90,7 @@ func IP(name string, value net.IP, usage string) *net.IP { return CommandLine.IPP(name, "", value, usage) } -// Like IP, but accepts a shorthand letter that can be used after a single dash. +// IPP is like IP, but accepts a shorthand letter that can be used after a single dash. func IPP(name, shorthand string, value net.IP, usage string) *net.IP { return CommandLine.IPP(name, shorthand, value, usage) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/ipmask.go b/Godeps/_workspace/src/github.com/spf13/pflag/ipmask.go index 1b10efb4747..5bd44bd21d2 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/ipmask.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/ipmask.go @@ -28,7 +28,7 @@ func (i *ipMaskValue) Type() string { return "ipMask" } -// Parse IPv4 netmask written in IP form (e.g. 255.255.255.0). +// ParseIPv4Mask written in IP form (e.g. 255.255.255.0). // This function should really belong to the net package. func ParseIPv4Mask(s string) net.IPMask { mask := net.ParseIP(s) @@ -79,7 +79,7 @@ func (f *FlagSet) IPMaskVar(p *net.IPMask, name string, value net.IPMask, usage f.VarP(newIPMaskValue(value, p), name, "", usage) } -// Like IPMaskVar, but accepts a shorthand letter that can be used after a single dash. +// IPMaskVarP is like IPMaskVar, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) IPMaskVarP(p *net.IPMask, name, shorthand string, value net.IPMask, usage string) { f.VarP(newIPMaskValue(value, p), name, shorthand, usage) } @@ -90,7 +90,7 @@ func IPMaskVar(p *net.IPMask, name string, value net.IPMask, usage string) { CommandLine.VarP(newIPMaskValue(value, p), name, "", usage) } -// Like IPMaskVar, but accepts a shorthand letter that can be used after a single dash. +// IPMaskVarP is like IPMaskVar, but accepts a shorthand letter that can be used after a single dash. func IPMaskVarP(p *net.IPMask, name, shorthand string, value net.IPMask, usage string) { CommandLine.VarP(newIPMaskValue(value, p), name, shorthand, usage) } @@ -103,7 +103,7 @@ func (f *FlagSet) IPMask(name string, value net.IPMask, usage string) *net.IPMas return p } -// Like IPMask, but accepts a shorthand letter that can be used after a single dash. +// IPMaskP is like IPMask, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) IPMaskP(name, shorthand string, value net.IPMask, usage string) *net.IPMask { p := new(net.IPMask) f.IPMaskVarP(p, name, shorthand, value, usage) @@ -116,7 +116,7 @@ func IPMask(name string, value net.IPMask, usage string) *net.IPMask { return CommandLine.IPMaskP(name, "", value, usage) } -// Like IP, but accepts a shorthand letter that can be used after a single dash. +// IPMaskP is like IP, but accepts a shorthand letter that can be used after a single dash. func IPMaskP(name, shorthand string, value net.IPMask, usage string) *net.IPMask { return CommandLine.IPMaskP(name, shorthand, value, usage) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/ipnet.go b/Godeps/_workspace/src/github.com/spf13/pflag/ipnet.go index 23b7fd3cc0a..149b764b1e8 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/ipnet.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/ipnet.go @@ -7,31 +7,31 @@ import ( ) // IPNet adapts net.IPNet for use as a flag. -type IPNetValue net.IPNet +type ipNetValue net.IPNet -func (ipnet IPNetValue) String() string { +func (ipnet ipNetValue) String() string { n := net.IPNet(ipnet) return n.String() } -func (ipnet *IPNetValue) Set(value string) error { +func (ipnet *ipNetValue) Set(value string) error { _, n, err := net.ParseCIDR(strings.TrimSpace(value)) if err != nil { return err } - *ipnet = IPNetValue(*n) + *ipnet = ipNetValue(*n) return nil } -func (*IPNetValue) Type() string { +func (*ipNetValue) Type() string { return "ipNet" } var _ = strings.TrimSpace -func newIPNetValue(val net.IPNet, p *net.IPNet) *IPNetValue { +func newIPNetValue(val net.IPNet, p *net.IPNet) *ipNetValue { *p = val - return (*IPNetValue)(p) + return (*ipNetValue)(p) } func ipNetConv(sval string) (interface{}, error) { @@ -57,7 +57,7 @@ func (f *FlagSet) IPNetVar(p *net.IPNet, name string, value net.IPNet, usage str f.VarP(newIPNetValue(value, p), name, "", usage) } -// Like IPNetVar, but accepts a shorthand letter that can be used after a single dash. +// IPNetVarP is like IPNetVar, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) IPNetVarP(p *net.IPNet, name, shorthand string, value net.IPNet, usage string) { f.VarP(newIPNetValue(value, p), name, shorthand, usage) } @@ -68,7 +68,7 @@ func IPNetVar(p *net.IPNet, name string, value net.IPNet, usage string) { CommandLine.VarP(newIPNetValue(value, p), name, "", usage) } -// Like IPNetVar, but accepts a shorthand letter that can be used after a single dash. +// IPNetVarP is like IPNetVar, but accepts a shorthand letter that can be used after a single dash. func IPNetVarP(p *net.IPNet, name, shorthand string, value net.IPNet, usage string) { CommandLine.VarP(newIPNetValue(value, p), name, shorthand, usage) } @@ -81,7 +81,7 @@ func (f *FlagSet) IPNet(name string, value net.IPNet, usage string) *net.IPNet { return p } -// Like IPNet, but accepts a shorthand letter that can be used after a single dash. +// IPNetP is like IPNet, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) IPNetP(name, shorthand string, value net.IPNet, usage string) *net.IPNet { p := new(net.IPNet) f.IPNetVarP(p, name, shorthand, value, usage) @@ -94,7 +94,7 @@ func IPNet(name string, value net.IPNet, usage string) *net.IPNet { return CommandLine.IPNetP(name, "", value, usage) } -// Like IPNet, but accepts a shorthand letter that can be used after a single dash. +// IPNetP is like IPNet, but accepts a shorthand letter that can be used after a single dash. func IPNetP(name, shorthand string, value net.IPNet, usage string) *net.IPNet { return CommandLine.IPNetP(name, shorthand, value, usage) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/string.go b/Godeps/_workspace/src/github.com/spf13/pflag/string.go index f89ea8b5149..e296136e5b8 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/string.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/string.go @@ -39,7 +39,7 @@ func (f *FlagSet) StringVar(p *string, name string, value string, usage string) f.VarP(newStringValue(value, p), name, "", usage) } -// Like StringVar, but accepts a shorthand letter that can be used after a single dash. +// StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) StringVarP(p *string, name, shorthand string, value string, usage string) { f.VarP(newStringValue(value, p), name, shorthand, usage) } @@ -50,7 +50,7 @@ func StringVar(p *string, name string, value string, usage string) { CommandLine.VarP(newStringValue(value, p), name, "", usage) } -// Like StringVar, but accepts a shorthand letter that can be used after a single dash. +// StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash. func StringVarP(p *string, name, shorthand string, value string, usage string) { CommandLine.VarP(newStringValue(value, p), name, shorthand, usage) } @@ -63,7 +63,7 @@ func (f *FlagSet) String(name string, value string, usage string) *string { return p } -// Like String, but accepts a shorthand letter that can be used after a single dash. +// StringP is like String, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) StringP(name, shorthand string, value string, usage string) *string { p := new(string) f.StringVarP(p, name, shorthand, value, usage) @@ -76,7 +76,7 @@ func String(name string, value string, usage string) *string { return CommandLine.StringP(name, "", value, usage) } -// Like String, but accepts a shorthand letter that can be used after a single dash. +// StringP is like String, but accepts a shorthand letter that can be used after a single dash. func StringP(name, shorthand string, value string, usage string) *string { return CommandLine.StringP(name, shorthand, value, usage) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/string_slice.go b/Godeps/_workspace/src/github.com/spf13/pflag/string_slice.go index 848bea891a0..0b7ddfe3d6f 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/string_slice.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/string_slice.go @@ -62,7 +62,7 @@ func (f *FlagSet) StringSliceVar(p *[]string, name string, value []string, usage f.VarP(newStringSliceValue(value, p), name, "", usage) } -// Like StringSliceVar, but accepts a shorthand letter that can be used after a single dash. +// StringSliceVarP is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) StringSliceVarP(p *[]string, name, shorthand string, value []string, usage string) { f.VarP(newStringSliceValue(value, p), name, shorthand, usage) } @@ -73,7 +73,7 @@ func StringSliceVar(p *[]string, name string, value []string, usage string) { CommandLine.VarP(newStringSliceValue(value, p), name, "", usage) } -// Like StringSliceVar, but accepts a shorthand letter that can be used after a single dash. +// StringSliceVarP is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash. func StringSliceVarP(p *[]string, name, shorthand string, value []string, usage string) { CommandLine.VarP(newStringSliceValue(value, p), name, shorthand, usage) } @@ -81,14 +81,14 @@ func StringSliceVarP(p *[]string, name, shorthand string, value []string, usage // StringSlice defines a string flag with specified name, default value, and usage string. // The return value is the address of a []string variable that stores the value of the flag. func (f *FlagSet) StringSlice(name string, value []string, usage string) *[]string { - p := make([]string, 0) + p := []string{} f.StringSliceVarP(&p, name, "", value, usage) return &p } -// Like StringSlice, but accepts a shorthand letter that can be used after a single dash. +// StringSliceP is like StringSlice, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) StringSliceP(name, shorthand string, value []string, usage string) *[]string { - p := make([]string, 0) + p := []string{} f.StringSliceVarP(&p, name, shorthand, value, usage) return &p } @@ -99,7 +99,7 @@ func StringSlice(name string, value []string, usage string) *[]string { return CommandLine.StringSliceP(name, "", value, usage) } -// Like StringSlice, but accepts a shorthand letter that can be used after a single dash. +// StringSliceP is like StringSlice, but accepts a shorthand letter that can be used after a single dash. func StringSliceP(name, shorthand string, value []string, usage string) *[]string { return CommandLine.StringSliceP(name, shorthand, value, usage) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/string_slice_test.go b/Godeps/_workspace/src/github.com/spf13/pflag/string_slice_test.go index e8847d5492b..97602de591e 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/string_slice_test.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/string_slice_test.go @@ -12,13 +12,13 @@ import ( func setUpSSFlagSet(ssp *[]string) *FlagSet { f := NewFlagSet("test", ContinueOnError) - f.StringSliceVar(ssp, "ss", []string{}, "Command seperated list!") + f.StringSliceVar(ssp, "ss", []string{}, "Command separated list!") return f } func setUpSSFlagSetWithDefault(ssp *[]string) *FlagSet { f := NewFlagSet("test", ContinueOnError) - f.StringSliceVar(ssp, "ss", []string{"default", "values"}, "Command seperated list!") + f.StringSliceVar(ssp, "ss", []string{"default", "values"}, "Command separated list!") return f } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/uint.go b/Godeps/_workspace/src/github.com/spf13/pflag/uint.go index d6f8e5be453..e142b49964e 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/uint.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/uint.go @@ -48,7 +48,7 @@ func (f *FlagSet) UintVar(p *uint, name string, value uint, usage string) { f.VarP(newUintValue(value, p), name, "", usage) } -// Like UintVar, but accepts a shorthand letter that can be used after a single dash. +// UintVarP is like UintVar, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) UintVarP(p *uint, name, shorthand string, value uint, usage string) { f.VarP(newUintValue(value, p), name, shorthand, usage) } @@ -59,7 +59,7 @@ func UintVar(p *uint, name string, value uint, usage string) { CommandLine.VarP(newUintValue(value, p), name, "", usage) } -// Like UintVar, but accepts a shorthand letter that can be used after a single dash. +// UintVarP is like UintVar, but accepts a shorthand letter that can be used after a single dash. func UintVarP(p *uint, name, shorthand string, value uint, usage string) { CommandLine.VarP(newUintValue(value, p), name, shorthand, usage) } @@ -72,7 +72,7 @@ func (f *FlagSet) Uint(name string, value uint, usage string) *uint { return p } -// Like Uint, but accepts a shorthand letter that can be used after a single dash. +// UintP is like Uint, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) UintP(name, shorthand string, value uint, usage string) *uint { p := new(uint) f.UintVarP(p, name, shorthand, value, usage) @@ -85,7 +85,7 @@ func Uint(name string, value uint, usage string) *uint { return CommandLine.UintP(name, "", value, usage) } -// Like Uint, but accepts a shorthand letter that can be used after a single dash. +// UintP is like Uint, but accepts a shorthand letter that can be used after a single dash. func UintP(name, shorthand string, value uint, usage string) *uint { return CommandLine.UintP(name, shorthand, value, usage) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/uint16.go b/Godeps/_workspace/src/github.com/spf13/pflag/uint16.go index 1cdc3dfbc09..5c96c19dcf4 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/uint16.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/uint16.go @@ -46,7 +46,7 @@ func (f *FlagSet) Uint16Var(p *uint16, name string, value uint16, usage string) f.VarP(newUint16Value(value, p), name, "", usage) } -// Like Uint16Var, but accepts a shorthand letter that can be used after a single dash. +// Uint16VarP is like Uint16Var, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Uint16VarP(p *uint16, name, shorthand string, value uint16, usage string) { f.VarP(newUint16Value(value, p), name, shorthand, usage) } @@ -57,7 +57,7 @@ func Uint16Var(p *uint16, name string, value uint16, usage string) { CommandLine.VarP(newUint16Value(value, p), name, "", usage) } -// Like Uint16Var, but accepts a shorthand letter that can be used after a single dash. +// Uint16VarP is like Uint16Var, but accepts a shorthand letter that can be used after a single dash. func Uint16VarP(p *uint16, name, shorthand string, value uint16, usage string) { CommandLine.VarP(newUint16Value(value, p), name, shorthand, usage) } @@ -70,7 +70,7 @@ func (f *FlagSet) Uint16(name string, value uint16, usage string) *uint16 { return p } -// Like Uint16, but accepts a shorthand letter that can be used after a single dash. +// Uint16P is like Uint16, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Uint16P(name, shorthand string, value uint16, usage string) *uint16 { p := new(uint16) f.Uint16VarP(p, name, shorthand, value, usage) @@ -83,7 +83,7 @@ func Uint16(name string, value uint16, usage string) *uint16 { return CommandLine.Uint16P(name, "", value, usage) } -// Like Uint16, but accepts a shorthand letter that can be used after a single dash. +// Uint16P is like Uint16, but accepts a shorthand letter that can be used after a single dash. func Uint16P(name, shorthand string, value uint16, usage string) *uint16 { return CommandLine.Uint16P(name, shorthand, value, usage) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/uint32.go b/Godeps/_workspace/src/github.com/spf13/pflag/uint32.go index 1326e4ab5d6..294fcaa32df 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/uint32.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/uint32.go @@ -46,7 +46,7 @@ func (f *FlagSet) Uint32Var(p *uint32, name string, value uint32, usage string) f.VarP(newUint32Value(value, p), name, "", usage) } -// Like Uint32Var, but accepts a shorthand letter that can be used after a single dash. +// Uint32VarP is like Uint32Var, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Uint32VarP(p *uint32, name, shorthand string, value uint32, usage string) { f.VarP(newUint32Value(value, p), name, shorthand, usage) } @@ -57,7 +57,7 @@ func Uint32Var(p *uint32, name string, value uint32, usage string) { CommandLine.VarP(newUint32Value(value, p), name, "", usage) } -// Like Uint32Var, but accepts a shorthand letter that can be used after a single dash. +// Uint32VarP is like Uint32Var, but accepts a shorthand letter that can be used after a single dash. func Uint32VarP(p *uint32, name, shorthand string, value uint32, usage string) { CommandLine.VarP(newUint32Value(value, p), name, shorthand, usage) } @@ -70,7 +70,7 @@ func (f *FlagSet) Uint32(name string, value uint32, usage string) *uint32 { return p } -// Like Uint32, but accepts a shorthand letter that can be used after a single dash. +// Uint32P is like Uint32, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Uint32P(name, shorthand string, value uint32, usage string) *uint32 { p := new(uint32) f.Uint32VarP(p, name, shorthand, value, usage) @@ -83,7 +83,7 @@ func Uint32(name string, value uint32, usage string) *uint32 { return CommandLine.Uint32P(name, "", value, usage) } -// Like Uint32, but accepts a shorthand letter that can be used after a single dash. +// Uint32P is like Uint32, but accepts a shorthand letter that can be used after a single dash. func Uint32P(name, shorthand string, value uint32, usage string) *uint32 { return CommandLine.Uint32P(name, shorthand, value, usage) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/uint64.go b/Godeps/_workspace/src/github.com/spf13/pflag/uint64.go index 6788bbf8cd3..c68188505a6 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/uint64.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/uint64.go @@ -48,7 +48,7 @@ func (f *FlagSet) Uint64Var(p *uint64, name string, value uint64, usage string) f.VarP(newUint64Value(value, p), name, "", usage) } -// Like Uint64Var, but accepts a shorthand letter that can be used after a single dash. +// Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) { f.VarP(newUint64Value(value, p), name, shorthand, usage) } @@ -59,7 +59,7 @@ func Uint64Var(p *uint64, name string, value uint64, usage string) { CommandLine.VarP(newUint64Value(value, p), name, "", usage) } -// Like Uint64Var, but accepts a shorthand letter that can be used after a single dash. +// Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash. func Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) { CommandLine.VarP(newUint64Value(value, p), name, shorthand, usage) } @@ -72,7 +72,7 @@ func (f *FlagSet) Uint64(name string, value uint64, usage string) *uint64 { return p } -// Like Uint64, but accepts a shorthand letter that can be used after a single dash. +// Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Uint64P(name, shorthand string, value uint64, usage string) *uint64 { p := new(uint64) f.Uint64VarP(p, name, shorthand, value, usage) @@ -85,7 +85,7 @@ func Uint64(name string, value uint64, usage string) *uint64 { return CommandLine.Uint64P(name, "", value, usage) } -// Like Uint64, but accepts a shorthand letter that can be used after a single dash. +// Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash. func Uint64P(name, shorthand string, value uint64, usage string) *uint64 { return CommandLine.Uint64P(name, shorthand, value, usage) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/uint8.go b/Godeps/_workspace/src/github.com/spf13/pflag/uint8.go index 560c569b519..26db418adf6 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/uint8.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/uint8.go @@ -48,7 +48,7 @@ func (f *FlagSet) Uint8Var(p *uint8, name string, value uint8, usage string) { f.VarP(newUint8Value(value, p), name, "", usage) } -// Like Uint8Var, but accepts a shorthand letter that can be used after a single dash. +// Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) { f.VarP(newUint8Value(value, p), name, shorthand, usage) } @@ -59,7 +59,7 @@ func Uint8Var(p *uint8, name string, value uint8, usage string) { CommandLine.VarP(newUint8Value(value, p), name, "", usage) } -// Like Uint8Var, but accepts a shorthand letter that can be used after a single dash. +// Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash. func Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) { CommandLine.VarP(newUint8Value(value, p), name, shorthand, usage) } @@ -72,7 +72,7 @@ func (f *FlagSet) Uint8(name string, value uint8, usage string) *uint8 { return p } -// Like Uint8, but accepts a shorthand letter that can be used after a single dash. +// Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash. func (f *FlagSet) Uint8P(name, shorthand string, value uint8, usage string) *uint8 { p := new(uint8) f.Uint8VarP(p, name, shorthand, value, usage) @@ -85,7 +85,7 @@ func Uint8(name string, value uint8, usage string) *uint8 { return CommandLine.Uint8P(name, "", value, usage) } -// Like Uint8, but accepts a shorthand letter that can be used after a single dash. +// Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash. func Uint8P(name, shorthand string, value uint8, usage string) *uint8 { return CommandLine.Uint8P(name, shorthand, value, usage) } diff --git a/cmd/hyperkube/hyperkube.go b/cmd/hyperkube/hyperkube.go index 7b1ec231ccc..5272c5dd141 100644 --- a/cmd/hyperkube/hyperkube.go +++ b/cmd/hyperkube/hyperkube.go @@ -77,8 +77,8 @@ func (hk *HyperKube) Flags() *pflag.FlagSet { // These will add all of the "global" flags (defined with both the // flag and pflag packages) to the new flag set we have. - util.AddFlagSetToPFlagSet(flag.CommandLine, hk.baseFlags) - util.AddPFlagSetToPFlagSet(pflag.CommandLine, hk.baseFlags) + hk.baseFlags.AddGoFlagSet(flag.CommandLine) + hk.baseFlags.AddFlagSet(pflag.CommandLine) } return hk.baseFlags @@ -154,7 +154,7 @@ func (hk *HyperKube) Run(args []string) error { return err } - util.AddPFlagSetToPFlagSet(hk.Flags(), s.Flags()) + s.Flags().AddFlagSet(hk.Flags()) err = s.Flags().Parse(args) if err != nil || hk.helpFlagVal { if err != nil { diff --git a/cmd/hyperkube/hyperkube_test.go b/cmd/hyperkube/hyperkube_test.go index 55f04978df3..26cd6335e39 100644 --- a/cmd/hyperkube/hyperkube_test.go +++ b/cmd/hyperkube/hyperkube_test.go @@ -126,7 +126,7 @@ func TestServerHelp(t *testing.T) { x := runFull(t, "hyperkube test1 --help") assert.NoError(t, x.err) assert.Contains(t, x.output, "A simple server named test1") - assert.Contains(t, x.output, "--help=false: help for hyperkube") + assert.Contains(t, x.output, "--help[=false]: help for hyperkube") assert.NotContains(t, x.output, "test1 Run") } @@ -134,7 +134,7 @@ func TestServerFlagsBad(t *testing.T) { x := runFull(t, "hyperkube test1 --bad-flag") assert.EqualError(t, x.err, "unknown flag: --bad-flag") assert.Contains(t, x.output, "A simple server named test1") - assert.Contains(t, x.output, "--help=false: help for hyperkube") + assert.Contains(t, x.output, "--help[=false]: help for hyperkube") assert.NotContains(t, x.output, "test1 Run") } diff --git a/contrib/completions/bash/kubectl b/contrib/completions/bash/kubectl index 68fbcfff66a..b3174e1ea97 100644 --- a/contrib/completions/bash/kubectl +++ b/contrib/completions/bash/kubectl @@ -82,6 +82,12 @@ __handle_filename_extension_flag() _filedir "@(${ext})" } +__handle_subdirs_in_dir_flag() +{ + local dir="$1" + pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 +} + __handle_flag() { __debug "${FUNCNAME}: c is $c words[c] is ${words[c]}" diff --git a/contrib/mesos/cmd/km/hyperkube.go b/contrib/mesos/cmd/km/hyperkube.go index 47ddbd45362..abce229b9ea 100644 --- a/contrib/mesos/cmd/km/hyperkube.go +++ b/contrib/mesos/cmd/km/hyperkube.go @@ -75,8 +75,8 @@ func (hk *HyperKube) Flags() *pflag.FlagSet { // These will add all of the "global" flags (defined with both the // flag and pflag packages) to the new flag set we have. - util.AddFlagSetToPFlagSet(flag.CommandLine, hk.baseFlags) - util.AddPFlagSetToPFlagSet(pflag.CommandLine, hk.baseFlags) + hk.baseFlags.AddGoFlagSet(flag.CommandLine) + hk.baseFlags.AddFlagSet(pflag.CommandLine) } return hk.baseFlags @@ -152,7 +152,7 @@ func (hk *HyperKube) Run(args []string) error { return err } - util.AddPFlagSetToPFlagSet(hk.Flags(), s.Flags()) + s.Flags().AddFlagSet(hk.Flags()) err = s.Flags().Parse(args) if err != nil || hk.helpFlagVal { if err != nil { diff --git a/contrib/mesos/cmd/km/hyperkube_test.go b/contrib/mesos/cmd/km/hyperkube_test.go index a114c57a802..74739710c4c 100644 --- a/contrib/mesos/cmd/km/hyperkube_test.go +++ b/contrib/mesos/cmd/km/hyperkube_test.go @@ -125,7 +125,7 @@ func TestServerHelp(t *testing.T) { x := runFull(t, "hyperkube test1 --help") assert.NoError(t, x.err) assert.Contains(t, x.output, "A simple server named test1") - assert.Contains(t, x.output, "--help=false: help for hyperkube") + assert.Contains(t, x.output, "--help[=false]: help for hyperkube") assert.NotContains(t, x.output, "test1 Run") } @@ -133,7 +133,7 @@ func TestServerFlagsBad(t *testing.T) { x := runFull(t, "hyperkube test1 --bad-flag") assert.EqualError(t, x.err, "unknown flag: --bad-flag") assert.Contains(t, x.output, "A simple server named test1") - assert.Contains(t, x.output, "--help=false: help for hyperkube") + assert.Contains(t, x.output, "--help[=false]: help for hyperkube") assert.NotContains(t, x.output, "test1 Run") } diff --git a/docs/user-guide/kubectl/kubectl.md b/docs/user-guide/kubectl/kubectl.md index 48ecea1d148..304c557bbf4 100644 --- a/docs/user-guide/kubectl/kubectl.md +++ b/docs/user-guide/kubectl/kubectl.md @@ -49,7 +49,7 @@ kubectl ### Options ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -60,9 +60,9 @@ kubectl --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -102,7 +102,7 @@ kubectl * [kubectl stop](kubectl_stop.md) - Deprecated: Gracefully shut down a resource by name or filename. * [kubectl version](kubectl_version.md) - Print the client and server version information. -###### Auto generated by spf13/cobra at 2015-08-12 21:51:38.841032313 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.481555644 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_annotate.md b/docs/user-guide/kubectl/kubectl_annotate.md index 2b8b9c33a79..0a5d64ada1c 100644 --- a/docs/user-guide/kubectl/kubectl_annotate.md +++ b/docs/user-guide/kubectl/kubectl_annotate.md @@ -93,7 +93,7 @@ $ kubectl annotate pods foo description- ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -103,9 +103,9 @@ $ kubectl annotate pods foo description- --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -123,7 +123,7 @@ $ kubectl annotate pods foo description- * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-13 08:45:23.477684199 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.4790376 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_annotate.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_api-versions.md b/docs/user-guide/kubectl/kubectl_api-versions.md index 63612ffc1c8..7f6e229376a 100644 --- a/docs/user-guide/kubectl/kubectl_api-versions.md +++ b/docs/user-guide/kubectl/kubectl_api-versions.md @@ -53,7 +53,7 @@ kubectl api-versions ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -63,9 +63,9 @@ kubectl api-versions --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -83,7 +83,7 @@ kubectl api-versions * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-07 07:32:08.138043968 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.481201276 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_api-versions.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_attach.md b/docs/user-guide/kubectl/kubectl_attach.md index 3bc263bdea1..edd63acc922 100644 --- a/docs/user-guide/kubectl/kubectl_attach.md +++ b/docs/user-guide/kubectl/kubectl_attach.md @@ -70,7 +70,7 @@ $ kubectl attach 123456-7890 -c ruby-container -i -t ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -80,9 +80,9 @@ $ kubectl attach 123456-7890 -c ruby-container -i -t --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -100,7 +100,7 @@ $ kubectl attach 123456-7890 -c ruby-container -i -t * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-12 16:38:35.552121602 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.477447179 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_attach.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_cluster-info.md b/docs/user-guide/kubectl/kubectl_cluster-info.md index dabfc1327d0..aaf27291800 100644 --- a/docs/user-guide/kubectl/kubectl_cluster-info.md +++ b/docs/user-guide/kubectl/kubectl_cluster-info.md @@ -53,7 +53,7 @@ kubectl cluster-info ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -63,9 +63,9 @@ kubectl cluster-info --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -83,7 +83,7 @@ kubectl cluster-info * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-05 14:22:30.877534441 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.481057477 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_cluster-info.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_config.md b/docs/user-guide/kubectl/kubectl_config.md index 09e20ead1a8..9c19eea12b7 100644 --- a/docs/user-guide/kubectl/kubectl_config.md +++ b/docs/user-guide/kubectl/kubectl_config.md @@ -60,7 +60,7 @@ kubectl config SUBCOMMAND ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -69,9 +69,9 @@ kubectl config SUBCOMMAND --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -96,7 +96,7 @@ kubectl config SUBCOMMAND * [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a kubeconfig file * [kubectl config view](kubectl_config_view.md) - displays Merged kubeconfig settings or a specified kubeconfig file. -###### Auto generated by spf13/cobra at 2015-08-05 14:22:30.877353612 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.480913444 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_config_set-cluster.md b/docs/user-guide/kubectl/kubectl_config_set-cluster.md index 999cf637a52..6316ff98475 100644 --- a/docs/user-guide/kubectl/kubectl_config_set-cluster.md +++ b/docs/user-guide/kubectl/kubectl_config_set-cluster.md @@ -61,27 +61,27 @@ $ kubectl config set-cluster e2e --insecure-skip-tls-verify=true ### Options ``` - --api-version=: api-version for the cluster entry in kubeconfig - --certificate-authority=: path to certificate-authority for the cluster entry in kubeconfig + --api-version="": api-version for the cluster entry in kubeconfig + --certificate-authority="": path to certificate-authority for the cluster entry in kubeconfig --embed-certs=false: embed-certs for the cluster entry in kubeconfig -h, --help[=false]: help for set-cluster --insecure-skip-tls-verify=false: insecure-skip-tls-verify for the cluster entry in kubeconfig - --server=: server for the cluster entry in kubeconfig + --server="": server for the cluster entry in kubeconfig ``` ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --client-certificate="": Path to a client key file for TLS. --client-key="": Path to a client key file for TLS. --cluster="": The name of the kubeconfig cluster to use --context="": The name of the kubeconfig context to use --kubeconfig="": use a particular kubeconfig file --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -98,7 +98,7 @@ $ kubectl config set-cluster e2e --insecure-skip-tls-verify=true * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-08-12 16:38:35.5536843 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.479946549 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_set-cluster.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_config_set-context.md b/docs/user-guide/kubectl/kubectl_config_set-context.md index acd77f110e5..5bba7845c00 100644 --- a/docs/user-guide/kubectl/kubectl_config_set-context.md +++ b/docs/user-guide/kubectl/kubectl_config_set-context.md @@ -55,16 +55,16 @@ $ kubectl config set-context gce --user=cluster-admin ### Options ``` - --cluster=: cluster for the context entry in kubeconfig + --cluster="": cluster for the context entry in kubeconfig -h, --help[=false]: help for set-context - --namespace=: namespace for the context entry in kubeconfig - --user=: user for the context entry in kubeconfig + --namespace="": namespace for the context entry in kubeconfig + --user="": user for the context entry in kubeconfig ``` ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -73,9 +73,9 @@ $ kubectl config set-context gce --user=cluster-admin --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": use a particular kubeconfig file --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --password="": Password for basic authentication to the API server. -s, --server="": The address and port of the Kubernetes API server @@ -91,7 +91,7 @@ $ kubectl config set-context gce --user=cluster-admin * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-08-12 16:38:35.553957807 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.480303261 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_set-context.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_config_set-credentials.md b/docs/user-guide/kubectl/kubectl_config_set-credentials.md index 4b009a3fd0f..5c40501f531 100644 --- a/docs/user-guide/kubectl/kubectl_config_set-credentials.md +++ b/docs/user-guide/kubectl/kubectl_config_set-credentials.md @@ -74,19 +74,19 @@ $ kubectl config set-credentials cluster-admin --client-certificate=~/.kube/admi ### Options ``` - --client-certificate=: path to client-certificate for the user entry in kubeconfig - --client-key=: path to client-key for the user entry in kubeconfig + --client-certificate="": path to client-certificate for the user entry in kubeconfig + --client-key="": path to client-key for the user entry in kubeconfig --embed-certs=false: embed client cert/key for the user entry in kubeconfig -h, --help[=false]: help for set-credentials - --password=: password for the user entry in kubeconfig - --token=: token for the user entry in kubeconfig - --username=: username for the user entry in kubeconfig + --password="": password for the user entry in kubeconfig + --token="": token for the user entry in kubeconfig + --username="": username for the user entry in kubeconfig ``` ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --cluster="": The name of the kubeconfig cluster to use @@ -94,9 +94,9 @@ $ kubectl config set-credentials cluster-admin --client-certificate=~/.kube/admi --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": use a particular kubeconfig file --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. -s, --server="": The address and port of the Kubernetes API server @@ -111,7 +111,7 @@ $ kubectl config set-credentials cluster-admin --client-certificate=~/.kube/admi * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-08-12 16:38:35.553818643 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.480107057 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_set-credentials.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_config_set.md b/docs/user-guide/kubectl/kubectl_config_set.md index d46937ffe7c..1564ee2b13a 100644 --- a/docs/user-guide/kubectl/kubectl_config_set.md +++ b/docs/user-guide/kubectl/kubectl_config_set.md @@ -55,7 +55,7 @@ kubectl config set PROPERTY_NAME PROPERTY_VALUE ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -65,9 +65,9 @@ kubectl config set PROPERTY_NAME PROPERTY_VALUE --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": use a particular kubeconfig file --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -85,7 +85,7 @@ kubectl config set PROPERTY_NAME PROPERTY_VALUE * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-08-05 14:22:30.876800013 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.480452342 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_set.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_config_unset.md b/docs/user-guide/kubectl/kubectl_config_unset.md index 2e508aa3527..42e39438f51 100644 --- a/docs/user-guide/kubectl/kubectl_config_unset.md +++ b/docs/user-guide/kubectl/kubectl_config_unset.md @@ -54,7 +54,7 @@ kubectl config unset PROPERTY_NAME ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -64,9 +64,9 @@ kubectl config unset PROPERTY_NAME --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": use a particular kubeconfig file --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -84,7 +84,7 @@ kubectl config unset PROPERTY_NAME * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-08-05 14:22:30.876989795 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.480598704 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_unset.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_config_use-context.md b/docs/user-guide/kubectl/kubectl_config_use-context.md index adecd9f82e6..4ba8b725a69 100644 --- a/docs/user-guide/kubectl/kubectl_config_use-context.md +++ b/docs/user-guide/kubectl/kubectl_config_use-context.md @@ -53,7 +53,7 @@ kubectl config use-context CONTEXT_NAME ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -63,9 +63,9 @@ kubectl config use-context CONTEXT_NAME --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": use a particular kubeconfig file --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -83,7 +83,7 @@ kubectl config use-context CONTEXT_NAME * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-08-05 14:22:30.877169143 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.480752945 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_use-context.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_config_view.md b/docs/user-guide/kubectl/kubectl_config_view.md index 06e13690d22..b758dd7d0b6 100644 --- a/docs/user-guide/kubectl/kubectl_config_view.md +++ b/docs/user-guide/kubectl/kubectl_config_view.md @@ -75,7 +75,7 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2 ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -85,9 +85,9 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2 --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": use a particular kubeconfig file --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -105,7 +105,7 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2 * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-08-13 08:45:23.478129098 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.479773286 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_config_view.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_create.md b/docs/user-guide/kubectl/kubectl_create.md index d62a2ea0f37..cf1e6efbd19 100644 --- a/docs/user-guide/kubectl/kubectl_create.md +++ b/docs/user-guide/kubectl/kubectl_create.md @@ -67,7 +67,7 @@ $ cat pod.json | kubectl create -f - ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -77,9 +77,9 @@ $ cat pod.json | kubectl create -f - --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -97,7 +97,7 @@ $ cat pod.json | kubectl create -f - * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-12 16:38:35.550238308 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.475503857 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_create.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_delete.md b/docs/user-guide/kubectl/kubectl_delete.md index 6a18c9dbc7e..e9b3f32e822 100644 --- a/docs/user-guide/kubectl/kubectl_delete.md +++ b/docs/user-guide/kubectl/kubectl_delete.md @@ -88,7 +88,7 @@ $ kubectl delete pods --all ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -98,9 +98,9 @@ $ kubectl delete pods --all --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -118,7 +118,7 @@ $ kubectl delete pods --all * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-12 16:38:35.550716188 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.476048394 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_delete.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_describe.md b/docs/user-guide/kubectl/kubectl_describe.md index d75ed978c96..b7441b7f494 100644 --- a/docs/user-guide/kubectl/kubectl_describe.md +++ b/docs/user-guide/kubectl/kubectl_describe.md @@ -91,7 +91,7 @@ $ kubectl describe pods frontend ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -101,9 +101,9 @@ $ kubectl describe pods frontend --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -121,7 +121,7 @@ $ kubectl describe pods frontend * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-12 17:00:51.070612795 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.475314072 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_describe.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_exec.md b/docs/user-guide/kubectl/kubectl_exec.md index 64c6ef46179..32fe1647898 100644 --- a/docs/user-guide/kubectl/kubectl_exec.md +++ b/docs/user-guide/kubectl/kubectl_exec.md @@ -71,7 +71,7 @@ $ kubectl exec 123456-7890 -c ruby-container -i -t -- bash -il ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -81,9 +81,9 @@ $ kubectl exec 123456-7890 -c ruby-container -i -t -- bash -il --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -101,7 +101,7 @@ $ kubectl exec 123456-7890 -c ruby-container -i -t -- bash -il * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-12 16:38:35.552259405 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.477614406 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_exec.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_expose.md b/docs/user-guide/kubectl/kubectl_expose.md index 5da034512c3..39ac2ba5fed 100644 --- a/docs/user-guide/kubectl/kubectl_expose.md +++ b/docs/user-guide/kubectl/kubectl_expose.md @@ -94,7 +94,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -104,9 +104,9 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -124,7 +124,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-13 08:45:23.476872373 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.478645014 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_expose.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_get.md b/docs/user-guide/kubectl/kubectl_get.md index 2bfca8ae7eb..b4eb40e6926 100644 --- a/docs/user-guide/kubectl/kubectl_get.md +++ b/docs/user-guide/kubectl/kubectl_get.md @@ -101,7 +101,7 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7 ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -111,9 +111,9 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7 --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -131,7 +131,7 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7 * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-20 01:10:19.603989785 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.475080519 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_get.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_label.md b/docs/user-guide/kubectl/kubectl_label.md index ae776d89ec8..0af25cfcac3 100644 --- a/docs/user-guide/kubectl/kubectl_label.md +++ b/docs/user-guide/kubectl/kubectl_label.md @@ -91,7 +91,7 @@ $ kubectl label pods foo bar- ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -101,9 +101,9 @@ $ kubectl label pods foo bar- --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -121,7 +121,7 @@ $ kubectl label pods foo bar- * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-20 01:10:19.61318045 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.478848071 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_label.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_logs.md b/docs/user-guide/kubectl/kubectl_logs.md index 71101fb83e1..327aa1e0ee8 100644 --- a/docs/user-guide/kubectl/kubectl_logs.md +++ b/docs/user-guide/kubectl/kubectl_logs.md @@ -70,7 +70,7 @@ $ kubectl logs -f 123456-7890 ruby-container ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -80,9 +80,9 @@ $ kubectl logs -f 123456-7890 ruby-container --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -100,7 +100,7 @@ $ kubectl logs -f 123456-7890 ruby-container * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-12 16:38:35.55101853 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.476847461 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_logs.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_namespace.md b/docs/user-guide/kubectl/kubectl_namespace.md index 6e4465758a0..b72060824c4 100644 --- a/docs/user-guide/kubectl/kubectl_namespace.md +++ b/docs/user-guide/kubectl/kubectl_namespace.md @@ -56,7 +56,7 @@ kubectl namespace [namespace] ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -66,9 +66,9 @@ kubectl namespace [namespace] --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -86,7 +86,7 @@ kubectl namespace [namespace] * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-05 14:22:30.872853909 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.476203071 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_namespace.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_patch.md b/docs/user-guide/kubectl/kubectl_patch.md index 586c0e5cd2f..1e0b1c47256 100644 --- a/docs/user-guide/kubectl/kubectl_patch.md +++ b/docs/user-guide/kubectl/kubectl_patch.md @@ -74,7 +74,7 @@ kubectl patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -84,9 +84,9 @@ kubectl patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -104,7 +104,7 @@ kubectl patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-13 02:12:21.577994505 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.475848256 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_patch.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_port-forward.md b/docs/user-guide/kubectl/kubectl_port-forward.md index 0fd8a473914..688435b93c6 100644 --- a/docs/user-guide/kubectl/kubectl_port-forward.md +++ b/docs/user-guide/kubectl/kubectl_port-forward.md @@ -71,7 +71,7 @@ $ kubectl port-forward mypod 0:5000 ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -81,9 +81,9 @@ $ kubectl port-forward mypod 0:5000 --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -101,7 +101,7 @@ $ kubectl port-forward mypod 0:5000 * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-12 16:38:35.552397633 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.47778769 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_port-forward.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_proxy.md b/docs/user-guide/kubectl/kubectl_proxy.md index a87510e5093..19a3773e7d2 100644 --- a/docs/user-guide/kubectl/kubectl_proxy.md +++ b/docs/user-guide/kubectl/kubectl_proxy.md @@ -93,7 +93,7 @@ $ kubectl proxy --api-prefix=/k8s-api ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -103,9 +103,9 @@ $ kubectl proxy --api-prefix=/k8s-api --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -123,7 +123,7 @@ $ kubectl proxy --api-prefix=/k8s-api * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-12 16:38:35.55255853 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.477994494 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_proxy.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_replace.md b/docs/user-guide/kubectl/kubectl_replace.md index bf074f5ea04..94e51341d7a 100644 --- a/docs/user-guide/kubectl/kubectl_replace.md +++ b/docs/user-guide/kubectl/kubectl_replace.md @@ -81,7 +81,7 @@ kubectl replace --force -f ./pod.json ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -91,9 +91,9 @@ kubectl replace --force -f ./pod.json --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -111,7 +111,7 @@ kubectl replace --force -f ./pod.json * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-12 21:51:38.83671597 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.475684757 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_replace.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_rolling-update.md b/docs/user-guide/kubectl/kubectl_rolling-update.md index c65b2dd895c..68bfe75ee34 100644 --- a/docs/user-guide/kubectl/kubectl_rolling-update.md +++ b/docs/user-guide/kubectl/kubectl_rolling-update.md @@ -89,7 +89,7 @@ $ kubectl rolling-update frontend --image=image:v2 ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -99,9 +99,9 @@ $ kubectl rolling-update frontend --image=image:v2 --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -119,7 +119,7 @@ $ kubectl rolling-update frontend --image=image:v2 * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-20 01:10:19.606885893 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.477073189 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_rolling-update.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_run.md b/docs/user-guide/kubectl/kubectl_run.md index fc7b118d21d..810b0a34fbb 100644 --- a/docs/user-guide/kubectl/kubectl_run.md +++ b/docs/user-guide/kubectl/kubectl_run.md @@ -98,7 +98,7 @@ $ kubectl run nginx --image=nginx --command -- ... ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -108,9 +108,9 @@ $ kubectl run nginx --image=nginx --command -- ... --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -128,7 +128,7 @@ $ kubectl run nginx --image=nginx --command -- ... * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-14 06:15:57.11465464 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.478226341 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_run.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_scale.md b/docs/user-guide/kubectl/kubectl_scale.md index 0d049577a17..8ac54ac7be4 100644 --- a/docs/user-guide/kubectl/kubectl_scale.md +++ b/docs/user-guide/kubectl/kubectl_scale.md @@ -80,7 +80,7 @@ $ kubectl scale --replicas=5 rc/foo rc/bar ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -90,9 +90,9 @@ $ kubectl scale --replicas=5 rc/foo rc/bar --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -110,7 +110,7 @@ $ kubectl scale --replicas=5 rc/foo rc/bar * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-13 06:25:21.82766402 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.477281515 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_scale.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_stop.md b/docs/user-guide/kubectl/kubectl_stop.md index 1023ccb0caa..b409aac797a 100644 --- a/docs/user-guide/kubectl/kubectl_stop.md +++ b/docs/user-guide/kubectl/kubectl_stop.md @@ -82,7 +82,7 @@ $ kubectl stop -f path/to/resources ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -92,9 +92,9 @@ $ kubectl stop -f path/to/resources --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -112,7 +112,7 @@ $ kubectl stop -f path/to/resources * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-12 16:38:35.552901364 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.478408029 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_stop.md?pixel)]() diff --git a/docs/user-guide/kubectl/kubectl_version.md b/docs/user-guide/kubectl/kubectl_version.md index 46677c91284..b59fec6b1ab 100644 --- a/docs/user-guide/kubectl/kubectl_version.md +++ b/docs/user-guide/kubectl/kubectl_version.md @@ -54,7 +54,7 @@ kubectl version ### Options inherited from parent commands ``` - --alsologtostderr=false: log to standard error as well as files + --alsologtostderr[=false]: log to standard error as well as files --api-version="": The API version to use when talking to the server --certificate-authority="": Path to a cert. file for the certificate authority. --client-certificate="": Path to a client key file for TLS. @@ -64,9 +64,9 @@ kubectl version --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace - --log-dir=: If non-empty, write log files in this directory + --log-dir="": If non-empty, write log files in this directory --log-flush-frequency=5s: Maximum number of seconds between log flushes - --logtostderr=true: log to standard error instead of files + --logtostderr[=true]: log to standard error instead of files --match-server-version[=false]: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. --password="": Password for basic authentication to the API server. @@ -84,7 +84,7 @@ kubectl version * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-08-05 14:22:30.877888956 +0000 UTC +###### Auto generated by spf13/cobra at 2015-08-20 22:01:12.48136046 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_version.md?pixel)]() diff --git a/pkg/kubectl/cmd/util/factory.go b/pkg/kubectl/cmd/util/factory.go index 24e91ae9f5e..3fa6bbe51d7 100644 --- a/pkg/kubectl/cmd/util/factory.go +++ b/pkg/kubectl/cmd/util/factory.go @@ -271,11 +271,7 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory { // BindFlags adds any flags that are common to all kubectl sub commands. func (f *Factory) BindFlags(flags *pflag.FlagSet) { // any flags defined by external projects (not part of pflags) - util.AddFlagSetToPFlagSet(flag.CommandLine, flags) - - // This is necessary as github.com/spf13/cobra doesn't support "global" - // pflags currently. See https://github.com/spf13/cobra/issues/44. - util.AddPFlagSetToPFlagSet(pflag.CommandLine, flags) + flags.AddGoFlagSet(flag.CommandLine) // Hack for global access to validation flag. // TODO: Refactor out after configuration flag overhaul. @@ -284,7 +280,7 @@ func (f *Factory) BindFlags(flags *pflag.FlagSet) { } // Merge factory's flags - util.AddPFlagSetToPFlagSet(f.flags, flags) + flags.AddFlagSet(f.flags) // Globally persistent flags across all subcommands. // TODO Change flag names to consts to allow safer lookup from subcommands. diff --git a/pkg/util/flags.go b/pkg/util/flags.go index fb422c4cc11..3d5799243cf 100644 --- a/pkg/util/flags.go +++ b/pkg/util/flags.go @@ -16,10 +16,13 @@ limitations under the License. package util -import "strings" +import ( + goflag "flag" + "strings" -import "github.com/spf13/pflag" -import "github.com/golang/glog" + "github.com/golang/glog" + "github.com/spf13/pflag" +) // WordSepNormalizeFunc changes all flags that contain "_" separators func WordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName { @@ -43,6 +46,6 @@ func WarnWordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedNam // InitFlags normalizes and parses the command line flags func InitFlags() { pflag.CommandLine.SetNormalizeFunc(WordSepNormalizeFunc) - AddAllFlagsToPFlags() + pflag.CommandLine.AddGoFlagSet(goflag.CommandLine) pflag.Parse() } diff --git a/pkg/util/pflag_import.go b/pkg/util/pflag_import.go deleted file mode 100644 index 3e8d4d9ce8c..00000000000 --- a/pkg/util/pflag_import.go +++ /dev/null @@ -1,109 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package util - -import ( - "flag" - "reflect" - "strings" - - "github.com/spf13/pflag" -) - -// flagValueWrapper implements pflag.Value around a flag.Value. The main -// difference here is the addition of the Type method that returns a string -// name of the type. As this is generally unknown, we approximate that with -// reflection. -type flagValueWrapper struct { - inner flag.Value - flagType string -} - -func wrapFlagValue(v flag.Value) pflag.Value { - // If the flag.Value happens to also be a pflag.Value, just use it directly. - if pv, ok := v.(pflag.Value); ok { - return pv - } - - pv := &flagValueWrapper{ - inner: v, - } - - t := reflect.TypeOf(v) - if t.Kind() == reflect.Interface || t.Kind() == reflect.Ptr { - t = t.Elem() - } - - pv.flagType = t.Name() - pv.flagType = strings.TrimSuffix(pv.flagType, "Value") - return pv -} - -func (v *flagValueWrapper) String() string { - return v.inner.String() -} - -func (v *flagValueWrapper) Set(s string) error { - return v.inner.Set(s) -} - -func (v *flagValueWrapper) Type() string { - return v.flagType -} - -type boolFlag interface { - flag.Value - IsBoolFlag() bool -} - -func (v *flagValueWrapper) IsBoolFlag() bool { - if bv, ok := v.inner.(boolFlag); ok { - return bv.IsBoolFlag() - } - return false -} - -// Imports a 'flag.Flag' into a 'pflag.FlagSet'. The "short" option is unset -// and the type is inferred using reflection. -func addFlagToPFlagSet(f *flag.Flag, fs *pflag.FlagSet) { - if fs.Lookup(f.Name) == nil { - fs.Var(wrapFlagValue(f.Value), f.Name, f.Usage) - } -} - -// AddFlagSetToPFlagSet adds all of the flags in a 'flag.FlagSet' package flags to a 'pflag.FlagSet'. -func AddFlagSetToPFlagSet(fsIn *flag.FlagSet, fsOut *pflag.FlagSet) { - fsIn.VisitAll(func(f *flag.Flag) { - addFlagToPFlagSet(f, fsOut) - }) -} - -// AddAllFlagsToPFlags adds all of the top level 'flag' package flags to the top level 'pflag' flags. -func AddAllFlagsToPFlags() { - AddFlagSetToPFlagSet(flag.CommandLine, pflag.CommandLine) -} - -// AddPFlagSetToPFlagSet merges the flags of fsFrom into fsTo. -func AddPFlagSetToPFlagSet(fsFrom *pflag.FlagSet, fsTo *pflag.FlagSet) { - if fsFrom != nil && fsTo != nil { - fsFrom.VisitAll(func(f *pflag.Flag) { - if fsTo.Lookup(f.Name) == nil { - fsTo.AddFlag(f) - } - }) - } -}