aboutsummaryrefslogtreecommitdiff
path: root/flag.go
AgeCommit message (Collapse)Author
2025-08-29Reset args on re-parse even if emptyreset-args-even-if-emptyTomas Aschan
This ensures fs.Args() returns the expected thing after every parse. Fixes #439.
2025-08-29Merge branch 'master' into fix-errhelpTomas Aschan
2025-07-17Merge pull request #261 from dubrie/masterTomas Aschan
Switching from whitelist to Allowlist terminology. Fixes #294
2025-07-17Merge pull request #364 from vaguecoder/duplicate-errorTomas Aschan
Remove Redundant "Unknown-Flag" Error
2025-07-17Ensure output is written also from ParseAllTomas Aschan
2025-07-17Ensure output is written to correct streamTomas Aschan
2025-06-09fix help message for Func and BoolFunc flags #430Georges Varouchas
* have '.Type()' for boolfuncValue return "boolfunc" (dedicated value, which now makes it distinct from funcValue) * hide extra "(default )" by stating that "" should be treated as a zero value for a boolFlag note: - a boolfuncValue matches 'case boolFlag:', as it implements the boolFlag interface, - treating "" as a value which shouldn't trigger a "(default )" for a regular Bool flag does not look like a breaking change * hide extra "[=something]" for boolfuncValue * set default placeholder name for "boolfunc" and "func" flag types
2025-06-01Merge pull request #409 from ShawnJeffersonWang/masterTomas Aschan
fix: correct argument length check in FlagSet.Parse
2025-05-14Merge pull request #424 from valdar/issue/423Tomas Aschan
fix #423 : Add helper function and some documentation to parse shorthand go test flags.
2025-05-14fix #423 : Add helper function and some documentation to parse shorthand go ↵Andrea Tarocchi
test flags.
2025-04-21feat: Use error structs for most returned errorsEthan P.
This allows callers to differentiate between error types without having to parse the error message string.
2025-03-18Fix defaultIsZeroValue check for generic Value typeMidnightRocket
2024-07-23fix: correct argument length check in FlagSet.Parseshawn
Signed-off-by: shawn <[email protected]>
2024-06-12flag: Emulate stdlib behavior and do not print ErrHelpTravis Cline
2022-11-19Remove Redundant "Unknown-Flag" ErrorBhargav Ravuri
Signed-off-by: Bhargav Ravuri <[email protected]>
2020-06-02Switching from whitelist to Allowlist terminologyBill Johnson
2020-05-04Add exported functions to preserve `pkg/flag` compatibility (#220)Ryan McKern
* Rename out() to Output() This brings behavior inline with go's flag library, and allows for printing output directly to whatever the current FlagSet is using for output. This change will make it easier to correctly emit output to stdout or stderr (e.g. a user has requested a help screen, which should emit to stdout since it's the desired outcome). * improve compat. with pkg/flag by adding Name() pkg/flag has a public `Name()` function, which returns the name of the flag set when called. This commit adds that function, as well as a test for it. * Streamline testing Name() Testing `Name()` will move into its own explicit test, instead of running inline during `TestAddFlagSet()`. Co-authored-by: Chloe Kudryavtsev <[email protected]> Co-authored-by: Chloe Kudryavtsev <[email protected]>
2019-09-17Merge pull request #216 from therealmitchconnors/elegantMitch Connors
Implement SliceValue for better list semantics
2019-09-10Add SliceValue Commentstherealmitchconnors
2019-08-16Add first SliceValue implementationstherealmitchconnors
2019-06-16Fix package docDavid Schneider
Signed-off-by: David Schneider <[email protected]>
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-06-01Allow bubbling up of -test.* flags (#169)Joffrey F
Based on patch suggested here: https://github.com/spf13/cobra/issues/597#issuecomment-385984076
2018-04-12Typo correction in flag.go (#164)v1.0.1Saakallya Biswas
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-04-03make x.Parsed() return true after AddGoFlagSet(x) and pflag.Parse() (#162)childe
* make GoFlagSets.Parsed() true after pflag.Parse some third part lib such as glog use go flag package, and its some actions depends on if goflag.Parsed(). * add test case for goflag.CommandLine.Parsed() * add comment to goflag.CommandLine.Parsed test case
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
2018-03-28Add multiline wrapping support (#155)mkishere
* Add multiline wrapping support With reference to golang/go#20799, pflag now will respect newline in usage string and do wrap accordingly. Also add test cases for testing * Break at \n only if \n pos<wrap
2017-11-06Add uintSlice and boolSlice to name prettifier (#150)Steven Roose
2017-10-20Prevent printing when using ContinueOnError (#144)Steven Roose
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-30Generate flag error output for errors returned from the parseFunc (#138)Michael Porter
2017-09-01New: renamed intSlice to ints in usageChristophe Serafin
2017-09-01New: added a default name to avoid stringSlice in the usage message.Christophe Serafin
2017-05-05Testing for Shorthand LookupEric Paris
2017-05-05Add example to ShorthandLookupAlbert Nigmatzianov
2017-05-05Add note about panic in ShorthandLookupAlbert Nigmatzianov
2017-05-05Allow lookup by shorthand (#106)Charlie R.C
2017-04-27Unify error message for panic and f.outAlbert Nigmatzianov
2017-04-26Use comparison a string with "" instead of comparison of lenAlbert Nigmatzianov
2017-04-26Prevent parsing if there are no argumentsAlbert Nigmatzianov
2017-04-26Add more verbosity to panic of shorthand redefinitionAlbert Nigmatzianov
See https://github.com/spf13/cobra/issues/27#issuecomment-294690084
2017-04-26Use f.out in output flag deprecationAlbert Nigmatzianov
2017-04-26Make more detailed error in SetAlbert Nigmatzianov
2017-04-26Add comments for better understanding of parsing short flagsAlbert Nigmatzianov
2017-04-26Delete setFlagAlbert Nigmatzianov
2017-04-26Fix alreadythere variable nameAlbert Nigmatzianov
In some cases "exists" is better to understand
2017-04-18Merge pull request #119 from bogem/cachesortedeAlbert Nigmatzianov
Cache sorted flags
2017-04-17Merge pull request #75 from jonathanmarvens/patch-1Albert Nigmatzianov
Removed unused field "exitOnError".