aboutsummaryrefslogtreecommitdiff
path: root/flag_test.go
AgeCommit message (Collapse)Author
2018-08-31Fix panic when parsing unknown flag followed by empty argument (#173)v1.0.3Oren Shomron
Signed-off-by: Oren Shomron <[email protected]>
2018-04-10Allow Users To Show Deprecated Flags (#163)Eric Paris
They have to explicitly unhide a deprecated flag to keep the current behavior.
2018-03-30add ability to ignore unknown flags (#160)Rajat Jindal
* add ability to ignore unknown flags * add testcases * add 2 more patterns to the testcase * handle --unknownflag=val arg and -u=val arg scenario * add ParseErrorsWhiteList to extend error handling during parsing
2017-10-20Prevent printing when using ContinueOnError (#144)Steven Roose
2017-10-16add int16 flag (#143)Matthew Jaffee
* add int16 flag copied int32.go to int16.go and s/32/16 added a case to testParse in flag_test.go * test the set value of int16 flag
2017-10-08Remove redundant breakPontus Leitzler
2017-10-05Fixing Count flag usage string (#141)gonix
2017-10-02Fix SetNormalizeFunc (#137)Diego Becciolini
Related to https://github.com/spf13/cobra/issues/521
2017-09-01New: renamed intSlice to ints in usageChristophe Serafin
2017-09-01Fixed: updated unittestChristophe Serafin
2017-05-05Testing for Shorthand LookupEric Paris
2017-05-05Allow lookup by shorthand (#106)Charlie R.C
2017-04-12flag_test: fix go vet (#123)Tamir Duberstein
flag_test.go:338: result of fmt.Errorf call not used flag_test.go:377: no formatting directive in Errorf call
2017-04-05Prevent changing order of flags after SetNormalizeFunc() (#121)Albert Nigmatzianov
Fix #120
2017-03-25Add SortFlags option (#113)Albert Nigmatzianov
Fixes https://github.com/spf13/cobra/issues/316
2017-01-19Merge pull request #102 from bogem/redundantEric Paris
Clean up code
2017-01-16Make command line parsing available outside pflagxilabao
We basically want to allow callers to use our command line parser. There is a user who wants to log the command line, but they don't want to log "sensitive" flags. This allows that user to parse the command line and get each flag. They can use information in the flag to write their own printer.
2016-10-23Clean up codebogem
2016-09-09Fix default values for custom fieldsCameron Moore
Fallback to the original default detection logic if we have an unknown type. Fixes #91
2016-09-06add a new type StringArraywu8685
2016-08-16Refactor default value detectionCameron Moore
In Go 1.7 the default value for a time.Duration will change from "0" to "0s". This commit replaces the simplistic `isZeroValue` with a more intelligent implementation that checks for zero values based upon the specific type of the flag.
2015-12-18Issue #55: implement Go 1.5-style default usage formatting.Giovanni Bajo
Compare to 1.4, the main difference in formatting is the placement of default values. Moreover, UnquoteUsage() is now added (and exported, for full API compatibility with the standard flag package), so backtick words in usage messages can be used to set the placeholder name. Compared to the standard flag package, this patch always prints usage in one-line, with automatic alignment, because I feel that the 1.4 output is very confusing when modified to include also dash-dash flags.
2015-09-16Store the length of Args when a -- is found in commandlineEric Paris
This allows a program to know what args came before the -- and what args came after.
2015-09-07adding a private field to flags, and a function for marking flags as privateSteve Domino
removing some c/p left-overs from the MarkPrivate function, and updating the comment slightly changed field from Private to Hidden. Added documentation w/example to README.md. Added testing to confirm hidden flags updating test message
2015-08-20Add shorthand deprecatorJanet Kuo
2015-08-15New AddFlagSet function on FlagSetEric Paris
This function allows one to create a different FlagSets and then easily merge them together.
2015-08-15Fix up minor things found by goreportcard.comEric Paris
2015-08-07More tests for ChangedEric Paris
2015-08-07New helper to easily see if a flag has been setEric Paris
A lot easier than having to do it in the user over and over and over.
2015-06-22Add support for '--flag arg'Eric Paris
2015-06-22Set default values if no arg givenEric Paris
2015-06-22Merge pull request #25 from eparis/GetFlagTypeEric Paris
Add new FlagSet.Get{Int,String,...} accessor functions
2015-06-22Add SetAnnotation helperJordan Liggitt
2015-06-01Add new FlagSet.Get{Int,String,...} accessor functionsEric Paris
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...
2015-06-01Moar flag_test!Eric Paris
2015-05-19Added a test for normalizing usage nameAnastasis Andronidis
[close #23]
2015-05-10Call normalizeFlagName function only onceAnastasis Andronidis
2015-05-08Support bool= with shortnamesEric Paris
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.
2015-04-29Merge remote-tracking branch 'ogier/master' into mergeEric Paris
Conflicts: bool_test.go flag.go flag_test.go
2015-04-28Custom normalization funcEric Paris
This can be used however you want. My test is for flag aliases
2015-04-28Ability to mark flags as deprecatedEric Paris
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.
2015-04-27Merge pull request #12 from fabianofranz/masterEric Paris
Add support to short form with equal sign: -p=value
2015-04-23Allow WordSeparators to be set after flags are addedTim Hockin
2015-04-24Allow flag name normalization for compareTim Hockin
This allows the FlagSet to define equivalent word-separators. Given this, one can make - and _ equivalent, so --foo-bar and --foo_bar both work.
2015-04-22Add support to short form with equal sign: -p=valuefabianofranz
2015-02-17Fix handling of -- terminationAndy Goldstein
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.
2015-02-14Move test files to the 'pflag' packageAlex Ogier
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.
2015-01-16Fix unit tests to include Type() method in custom typesFilipe Brandenburger
This was broken by commit 463bdc838f2b35 ("Adding Type() method to the values.") which added the method to the interface but did not update the custom types in unit tests. Signed-off-by: Filipe Brandenburger <[email protected]>
2014-06-27Fixing issues so test pass againspf13
2014-04-02Compatibility: commandLine -> CommandLineAlec Thomas