| Age | Commit message (Collapse) | Author |
|
Add new StringSlice and IntSlice flag types
|
|
|
|
|
|
Arguments passed on the command line will be split on "," and will be
stored in a slice.
We can see this already exits in codegangsta/cli
https://github.com/codegangsta/cli/blob/44d40054fa6208a3013d7217aca72a2b8b0f5a0b/flag.go#L102
And people have written their own implementations for cobra/pflag
https://github.com/GoogleCloudPlatform/kubernetes/blob/c5ba95ee26cbec9694a780544b559a797956ea54/pkg/util/list.go
Lets just make it a first class flag
|
|
Add new FlagSet.Get{Int,String,...} accessor functions
|
|
Add SetAnnotation helper
|
|
|
|
If I declared a bool flag named "hello" I can now call
b, err := f.GetBool("hello")
And b will hold the value of the flag
We can see this is already done in
https://github.com/codegangsta/cli/blob/bcec9b08c7e5564f7512ad7e7b03778fe1923116/context.go
If people use the codegangsta/cli
Other projects have done it themselves using pflags (what inspired this
patch)
https://github.com/GoogleCloudPlatform/kubernetes/blob/cd817aebd848facda29e0befbbd6e31bf22402e6/pkg/kubectl/cmd/util/helpers.go#L176
Lets just do it ourselves...
|
|
Moar tests
|
|
|
|
These were only defined for a couple for flag types (ip, ipmask, uint16,
uint32) and weren't used anywhere. If you already knew the type well
enough to know that it was one of the few with a Get() interface, you
could cast yourself out of the Value...
|
|
Slight code cleanup parsing long flags
|
|
|
|
[close #23]
|
|
|
|
|
|
Call normalizeFlagName function only once
|
|
|
|
Support bool= with shortnames
|
|
Currently a shortname bool variable b cannot use the -b=true -b=false
form because the -b is assumed to mean true and the = format is never
noticed.
|
|
Parse rework
|
|
new function to parse each arg (less indentation)
make it clear what value is being set and where it came from
|
|
move the -- parsing up into the parent
make it more obvious which values we are using
|
|
Merge ogier/pflag and enable travis
|
|
Add docs and examples how to use the flag normalization func
|
|
|
|
|
|
Conflicts:
bool_test.go
flag.go
flag_test.go
|
|
Generic flag normalization
|
|
This can be used however you want. My test is for flag aliases
|
|
|
|
Ability to mark flags as deprecated
|
|
They will not show up in usage or help, but they will still work.
The usage message will print on os.Stderr any time the flag is set.
|
|
Declare Flag{ by name instead of order
|
|
Add support to short form with equal sign: -p=value
|
|
Allow WordSeparators to be set after flags are added
|
|
|
|
This allows the FlagSet to define equivalent word-separators. Given
this, one can make - and _ equivalent, so --foo-bar and --foo_bar both
work.
|
|
|
|
In order to be able to add new (unitialized) fields to Flags{} declare
fields by name instead of order
|
|
cobra.Command can make use of annotation in order to generate better
bash_completions
|
|
|
|
Fix handling of -- termination
|
|
Fix handling of -- termination. Previously, if you ran
$command -flag1 -etc -- some args after
the command's args would be doubled (some args after some args after).
Additionally, if there were items after the -- termination that looked
like flags, the parser would throw an error. It's better to terminate
parsing when -- is seen, because that usually indicates the caller wants
to pass the remainder of the arguments (including flags) as-is to
something else.
|
|
|
|
This means we can avoid putting the repository name into the source
files, so people who have their own forks don't have to make changes.
|
|
Add .travis.yml file
|
|
|
|
|
|
Bool value for spf13
|