aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-05-08Delete example, what isn't even shown in docsv1.0.0Albert Nigmatzianov
2017-05-05Testing for Shorthand LookupEric Paris
2017-05-05Add example to FlagSet.ShorthandLookupAlbert Nigmatzianov
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-05-02Add Go 1.8.1 to .travis.ymlAlbert Nigmatzianov
2017-05-02Update .travis.ymlAlbert Nigmatzianov
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-26Document Count functionAlbert Nigmatzianov
2017-04-26Delete setFlagAlbert Nigmatzianov
2017-04-26Fix alreadythere variable nameAlbert Nigmatzianov
In some cases "exists" is better to understand
2017-04-26Note about SortFlags in READMEAlbert Nigmatzianov
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".
2017-04-17Merge pull request #116 from bogem/fixdocsAlbert Nigmatzianov
Change `ogier` to `spf13` in docs and README
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-05Cache sorted flagsAlbert Nigmatzianov
As you can't delete flags in FlagSet, this method works Gainful performance improvement: benchmark old ns/op new ns/op delta BenchmarkVisitAll10Flags-4 1549 33.9 -97.81% BenchmarkVisit10Flags-4 1704 34.2 -97.99% benchmark old allocs new allocs delta BenchmarkVisitAll10Flags-4 3 0 -100.00% BenchmarkVisit10Flags-4 3 0 -100.00% benchmark old bytes new bytes delta BenchmarkVisitAll10Flags-4 272 0 -100.00% BenchmarkVisit10Flags-4 272 0 -100.00%
2017-04-05Prevent changing order of flags after SetNormalizeFunc() (#121)Albert Nigmatzianov
Fix #120
2017-03-27Modified to display a string default value as double quoted and escaped (#118)Matthew Winter
2017-03-25Add SortFlags option (#113)Albert Nigmatzianov
Fixes https://github.com/spf13/cobra/issues/316
2017-03-25Change `ogier` to `spf13` in docs and READMEAlbert Nigmatzianov
2017-01-30Add FlagSet.FlagUsagesWrapped(cols) which wraps to the given column (#105)Ian Campbell
This will allow applications to provide better help text without feeling constrained by how it will wrap even on 80 column displays etc. This has been a factor in tickets such as https://github.com/docker/docker/issues/18797. The basic wrapping algorithm is rather simplistic, it will look for the last whitespace (space or tab) before the given column and wrap there, indenting the continuation lines to match the usage text (i.e. aligned after the flag names themselves), e.g. when applied to `docker ps` wrapping at 70 columns (fairly narrow): Options: [...] -f, --filter filter Filter output based on conditions provided [...] -n, --last int Show n last created containers (includes all states) (default -1) -l, --latest Show the latest created container (includes all states) There are two main tweaks to this basic algorithm, first is to actually try and wrap to a soft limit 5 columns less than requested but allow the line to take up the full hard width if that prevents pushing a short word at the end of the string to the next line which looks odd, particuarly for usage which ends with "(default [])" and wraps the "[])" to the last line. Second if the display is too narrow, meaning after indentation for the flag names there is less than 24 columns allowed for the help text (24 chosen just by my eye and what I thought looked odd) then it will start the help text on the next line indented to the 16th column (16 chosen so as not to align with the first character of either the short of long flag name as 8 would, since that looked strange to me), e.g. wrapping the above example to a rather narrow 45 columns: Options: [...] -f, --filter filter Filter output based on conditions provided [...] -n, --last int Show n last created containers (includes all states) (default -1) -l, --latest Show the latest created container (includes all states) If even with starting the help on the next line there is still less than 24 characters of space available for the help text (implying columns < 24 + 16 == 40) just give up and return the unwrapped version (same as before this change). Signed-off-by: Ian Campbell <[email protected]>,
2017-01-25Add BoolSlice and UintSlice flag types. (#111)Jonathan Reyna
* Add Gogland/IntelliJ/Jetbrains config directory to .gitignore. * Added uint slice flag type. Added godoc for uint slice type. Added unit tests for new uint slice type. * Added new boolSliceValue type to handle []bool arguments. Added unit tests for new boolSliceValue type. Added godoc documentation. * Added new ipSliceValue type to handle []net.IP arguments. Added unit tests for new ipSliceValue type. Added godoc documentation. * Fix golint warnings. * boolSliceValue: - Use CSV parser for boolean flag arguments, and handle corner cases with extraneous quote characters. - Add unit tests for to parse flags with extraneous quote characters. - Add godoc documentation to undocumented methods. * boolSliceValue: - Refactored boolSlice name to boolStrSlice for clarity. - Fix allocation of out variable to len=0 (not len=cap) - Remove extraneous err declaration in range loop. - Actually append bool to []bool. - Simplify unit test function name. ipSliceValue: - Use csv parser for net.IP flag arguments, and handle corner cases with extraneous quote characters. - Add unit tests to parse flags with extraneous quote characters. - Add godoc documentation to undocumented methods. * boolSliceValue: ipSliceValue: - Use csv utility functions instead of duplicating code for reading and writing CSV flag string values.
2017-01-19Merge pull request #102 from bogem/redundantEric Paris
Clean up code
2017-01-16Merge pull request #110 from hardikbagdi/masterEric Paris
add badges to README.md
2017-01-16add badges to README.mdHardik Bagdi
2017-01-15Merge pull request #107 from xilabao/add-user-supplied-func-when-parseEric Paris
add user supplied function when parse()
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-12-13Merge pull request #109 from SinghamXiao/masterEric Paris
not enough arguments in call to flag.BoolVarP and too many arguments in call to flag.VarP
2016-12-14too many argumentsyuanxiao
Signed-off-by: yuanxiao <[email protected]>
2016-10-24Remove Go 1.5 from TravisBjørn Erik Pedersen
Fails to go get golint. Also bump Go 1.7 to 1.7.3
2016-10-23Clean up codebogem
2016-10-18Merge pull request #101 from dnephin/fix-default-value-of-stringEric Paris
Don't print escaped strings for the default value of string
2016-10-18Don't print escaped strings for the default value of string flags with a ↵Daniel Nephin
default is set. Signed-off-by: Daniel Nephin <[email protected]>
2016-10-18Merge pull request #100 from dnephin/dont-escape-windows-pathsEric Paris
Don't print escaped strings for the default value of string flags.
2016-10-18Don't print escaped strings for the default value of string flags.Daniel Nephin
Signed-off-by: Daniel Nephin <[email protected]>
2016-10-11Merge pull request #99 from mmilata/string-array-square-bracketsEric Paris
Fix square bracket handling in string_array
2016-10-11Fix square bracket handling in string_arrayMartin Milata
Same issue fixed in 13e924de for string_slice.
2016-10-06Merge pull request #98 from shenwei356/masterEric Paris
fix bug of string_slice with square brackets
2016-10-07fix bug of string_slice with square bracketsshenwei356
2016-10-05Merge pull request #94 from bogem/noverbsEric Paris
Optimize fmt statements
2016-09-25Optimize fmt statementsbogem
2016-09-15Merge pull request #93 from bogem/flagStringsEric Paris
Use strconv instead of fmt in some values' String funcs