| Age | Commit message (Collapse) | Author |
|
Signed-off-by: Gorka Lerchundi Osa <[email protected]>
|
|
Based on patch suggested here: https://github.com/spf13/cobra/issues/597#issuecomment-385984076
|
|
|
|
They have to explicitly unhide a deprecated flag to keep the current behavior.
|
|
* 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
|
|
* 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
|
|
* 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
|
|
BytesHex is an []byte represented as HEX-string
--bytes=010203040506070809 states for []bytes{1,2,3,4,5,6,7,8,9}
|
|
fixes #157
|
|
|
|
|
|
|
|
* 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
|
|
|
|
|
|
Related to https://github.com/spf13/cobra/issues/521
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See https://github.com/spf13/cobra/issues/27#issuecomment-294690084
|
|
|
|
|
|
|
|
|
|
|
|
In some cases "exists" is better to understand
|
|
|
|
Cache sorted flags
|
|
Removed unused field "exitOnError".
|
|
Change `ogier` to `spf13` in docs and README
|
|
flag_test.go:338: result of fmt.Errorf call not used
flag_test.go:377: no formatting directive in Errorf call
|
|
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%
|
|
Fix #120
|
|
|
|
Fixes https://github.com/spf13/cobra/issues/316
|
|
|
|
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]>,
|
|
* 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.
|