| Age | Commit message (Collapse) | Author |
|
fix: correct argument length check in FlagSet.Parse
|
|
Add tests to ensure invalid arguments and unknown flag error messages
don't change.
|
|
|
|
|
|
Signed-off-by: Mark Sagi-Kazar <[email protected]>
|
|
|
|
* 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]>
|
|
Signed-off-by: Oren Shomron <[email protected]>
|
|
They have to explicitly unhide a deprecated flag to keep the current behavior.
|
|
* 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 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
|
|
|
|
|
|
|
|
|
|
flag_test.go:338: result of fmt.Errorf call not used
flag_test.go:377: no formatting directive in Errorf call
|
|
Fix #120
|
|
Fixes https://github.com/spf13/cobra/issues/316
|
|
Clean up code
|
|
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.
|
|
|
|
Fallback to the original default detection logic if we have an unknown
type.
Fixes #91
|
|
|
|
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.
|
|
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.
|
|
This allows a program to know what args came before the -- and what args
came after.
|
|
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
|
|
|
|
This function allows one to create a different FlagSets and then easily
merge them together.
|
|
|
|
|
|
A lot easier than having to do it in the user over and over and over.
|
|
|
|
|
|
Add new FlagSet.Get{Int,String,...} accessor functions
|
|
|
|
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...
|
|
|
|
[close #23]
|
|
|
|
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.
|
|
Conflicts:
bool_test.go
flag.go
flag_test.go
|
|
This can be used however you want. My test is for flag aliases
|
|
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.
|
|
Add support to short form with equal sign: -p=value
|
|
|