Michael Schuett
9dd96e9e90
Add in Category to Flag interface
6 years ago
Michael Schuett
ff1c0b58dd
Start of category flag support
...
This adds what I think needs to be done to support categories for flags
but we will see if that works. It also forces the scripts to use python2
since they blow up under python3 which is becoming the default python on
many linux systems.
Small fix to app_test as well so it conforms to the new Flag interface.
6 years ago
Olivier Mengué
d7555e1729
Fix unnecessary uses of Sprintf
...
- use strconv directly
- use concatenation for "%s%s"
7 years ago
Joshua Rubin
37b7abb1c4
dont clobber slices with envvar
...
Signed-off-by: Joshua Rubin <jrubin@zvelo.com>
7 years ago
Jacob McCann
f971fca2b2
Allow FilePath to take []string
7 years ago
Brad Rydzewski
18a556e192
fix FilePath documentation in README.md
7 years ago
Brad Rydzewski
21fcab0dee
ability to load variable from file
7 years ago
Robert Liebowitz
b44660ac3d
Consider case when sorting strings
...
This makes sorting flags and other sections consistent with how most
command line tools function, by placing both flags `-A` and `-a` before
a flag `-B`.
7 years ago
Vladislav Mitov
0b665e6170
Add PathFlag
7 years ago
rliebz
11d45572f9
Export funcs to configure flag prefix/env hints
...
This will allow users to customize the prefix section or env hint
section of the flag entries in the help menu without having to
reimplement the rest of the logic required in defining FlagStringer.
7 years ago
Dan Buch
1505b9f046
Back out temporary flag alias whoopsie! 😅
7 years ago
Dan Buch
65b801c818
Resolve remaining test errors for v1 => v2 merge
7 years ago
Dan Buch
47a412375f
Resolved compile-time errors since merging from v1
7 years ago
Dan Buch
a61867e5e6
Merge remote-tracking branch 'origin/v1' into merging-from-v1
7 years ago
Joe Richey joerichey@google.com
1794792adf
Add ability to use custom Flag types
...
Users can now use custom flags types (conforming to the Flag interface)
in their applications. They can also use custom flags for the three
global flags (Help, Version, bash completion).
7 years ago
Jesse Szwedko
d71794de19
Make ApplyWithError a public method on errorableFlag
...
Add to altsrc flags. Otherwise, flagSet() was bypassing altsrc's attempt
at shadowing.
8 years ago
drekar
4661a59b20
errorableFlag: scope result of type assertion.
8 years ago
Jesse Szwedko
e367fafa3d
Return an error when parsing environment variables for values fails
...
Currently cli silently (aside from IntSlice and Int64Slice which oddly
printed directly to the error stream) ignores failures that occur when
parsing environment variables for their value for flags that define
environment variables. Instead, we should propogate up the error to the
user.
This is accomplished in a backwards compatible manner by adding a new,
internal, interface which defines an applyWithError function that all
flags here define. In v2, when we can modify the interface, we can drop
this secondary interface and modify `Apply` to return an error.
8 years ago
Jesse Szwedko
a00c3f5872
Consider empty environment variables as set
...
When assigning values to flags (also when interogatting via
`context.(Global)IsSet`.
For boolean flags, consider empty as `false`.
Using `syscall.Getenv` rather than `os.LookupEnv` in order to support
older Golang versions.
8 years ago
Jesse Szwedko
83497d2cda
Merge remote-tracking branch 'origin/master' into v2-merge
8 years ago
Antonio Murdaca
c516bce8f1
flags: provide a type to sort flags
...
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
8 years ago
lewo
6aa0ab6903
Merge branch 'v2' into v2-completion
8 years ago
Jake Champlin
7d56512ecc
Add documentation, remove quotes by default
8 years ago
Jake Champlin
e0556cf9e8
Add DefaultValue text for flags
...
Allows a user to override the default value of a flag in the displayed help output.
Ex:
```
cli.IntFlag{
Name: "foo, f",
DefaultText: "random foo",
Value: "bar",
}
```
Running `(app.name) -h` will now yield:
```
--foo value (default: "random foo")
```
Fixes : #504
8 years ago
Antoine Eiche
94bc26fd1c
Refactoring names from bash to shell
...
The refactoring is required since completion is also supported for zsh
shell.
Refactoring details:
- flag generate-bash-completion -> generate-completion
- var EnableBashCompletion -> EnableShellCompletion
- var BashComplete -> ShellComplete
- var BashCompletionFlag -> GenerateCompletionFlag
- type BashCompleteFunc -> ShellCompleteFunc
8 years ago
Antoine Eiche
7640bef0eb
Add --init-completion flag to print completion code
...
This flag takes as input 'bash' or 'zsh' and generates the completion
code for the specified shell.
8 years ago
Dan Buch
f7b2b93ffa
Merge remote-tracking branch 'origin/v1' into merging-from-v1
8 years ago
Bruno França dos Reis
028af4bc35
adding support for Float64SliceFlag
8 years ago
Dan Buch
6185b8d8fd
Generate code for flag types and context accessors
8 years ago
Dan Buch
0c9b549918
Ensure remaining v1 additions are v2 compatible
8 years ago
Dan Buch
6c628a1a88
Merge remote-tracking branch 'origin/v1' into merging-from-v1
8 years ago
Dan Buch
a0e694ed72
Add UintFlag, Uint64Flag types and supporting code
8 years ago
Dan Buch
537f5beb66
Tweaks to Int64Flag PR
8 years ago
Bruno França dos Reis
5c7cca7f16
Adding Int64Slice related stuff in flag.go and context.go, and related tests
8 years ago
Bruno França dos Reis
4962423cba
Adding Int64Flag type and related tests
8 years ago
Dan Buch
7cd5bed6cb
Backporting flagValue func from v2 branch
8 years ago
Joshua Rubin
f621deee5a
fix panic getting visible flags
8 years ago
Dan Buch
3b03164c92
Merge branch 'v2' into show-bool-default
8 years ago
Dan Buch
cd1e8c3452
Merge remote-tracking branch 'origin/v2' into minimize-struct-copying
8 years ago
Dan Buch
2b288769c7
Add comment about commaWhitespace stripping of flag.Name
8 years ago
Dan Buch
c70993dbc5
Merge branch 'v2' into minimize-struct-copying
8 years ago
Dan Buch
80f444e0f5
Merge branch 'v2' into clean-stringlies
8 years ago
Dan Buch
8f25dbb615
Ensure all flag aliases are set when Destination given
...
and extend "Incorrect Usage" message to show the error.
Closes #430
8 years ago
Dan Buch
ec05a8d31b
Ensure flag "Name" field values are un-stringly-fied
...
to (hopefully) help with bug triage & pinpointing usage issues since ripping out
stringly typed "Name".
8 years ago
Dan Buch
cd10b49473
Minimize struct copying
...
by using pointer func receivers and slices of struct pointers where possible.
8 years ago
Dan Buch
334e66cb8f
Remove unused (so far) func
8 years ago
Dan Buch
81fcf706ea
Replace all "stringly typed" fields with slice equivalents
...
and alter the Flag interface accordingly
Closes #415
8 years ago
Dan Buch
fac67ac91a
Show BoolFlag default value in help usage
...
now that BoolTFlag is gone
8 years ago
Dan Buch
f2d5ed9933
Replace BoolTFlag type with BoolFlag.Value
...
Closes #412
8 years ago
Dan Buch
32ebecfbb5
Merge remote-tracking branch 'origin/master' into v2
8 years ago
Matt Farina
07ce8bf79c
Cleaned up else per golint
...
When an if ends in a return the else is not required. golint
detects these conditions and found these.
8 years ago
Matt Farina
2f110bd745
Cleaned up exported func comments per golint
8 years ago
Dan Buch
bac790c819
Merge remote-tracking branch 'origin/master' into v2
8 years ago
Matt Farina
6f0b442222
Update to ErrWriter and make available on app
8 years ago
Matt Farina
2a256d4c53
Provide a variable for writing output with a default of os.Stderr
9 years ago
Dan Buch
a1e5328e30
Merge remote-tracking branch 'origin/master' into string-slice-flag-default-160
9 years ago
Dan Buch
cd92adcb75
Further simplifying default flag stringer func
9 years ago
Dan Buch
6089d723a8
Use existing `prefixedNames` func
9 years ago
Dan Buch
69a8e25f3d
Make flag usage rendering more consistent; show default values
9 years ago
Dan Buch
23af5dd643
Rename flag stringer func bits for clarity, consistency
9 years ago
Dan Buch
22773b14c1
Allow for pluggable flag-level help text formatting
...
by defining `cli.DefaultFlagStringFunc` with a default value that uses
`withEnvHint`, conditionally running a given flag's `FormatValueHelp` if
present.
Closes #257
9 years ago
Dan Buch
fed78b8bab
Rework of hidden flag impl plus some Action func corrections
9 years ago
Harshavardhana
99431669d0
New ``Hide`` variable for all Flags
...
This is a way to provide hidden flags for app, command and subcommands
For example:
--generate-bash-completion global flag shouldn't be printed along
with other flags as it might generally confuse people into thinking
that 'generate' in-fact would generate a bash completion file for them
to be used along with their app.
Also in general one would want to hide some flags for their apps.
9 years ago
Dan Buch
1a91f3dce5
Ensure IntSlice & StringSlice serialization works as expected
9 years ago
Dan Buch
d1b0c49a98
Ensure slice types can safely round-trip through flag.FlagSet
9 years ago
Dan Buch
64de53e639
Merge remote-tracking branch 'origin/master' into string-slice-flag-default-160
9 years ago
Kevin Cantwell
13b7eedc13
Parses usage placeholders via back quotes. Resolves #333
9 years ago
Dan Buch
7a5bfc850d
Update dangling IntSlice literal
9 years ago
Dan Buch
cb433e7468
Use NewIntSlice and NewStringSlice internally
9 years ago
Dan Buch
867aa0912d
Overwrite slice flag defaults when set
...
Closes #160
9 years ago
adamclerk
cde8418658
Fixes spelling issues and import alphabetical issues
...
Using goreportcard.com I noticed a few spelling errors. I really love codegangsta/cli
and wanted to help improve it.
9 years ago
Gregor Noczinski
09e2c89597
* Changed the way how to return the result. Because of strange ci failure
9 years ago
Gregor Noczinski
82ddbd9a07
* Improve GenericFlag.String() by suppressing empty "" for GenericFlags on nil or empty Generic.String()
...
* Cleanup StringFlag.String()
* Add os specific envHint handling for Windows (%ENV_VAR% instead of $ENV_VAR on posix systems)
9 years ago
Jille Timmermans
f101a00018
Export cli.Flag.GetName (previously cli.Flag.getName)
9 years ago
ston1th
25ef368235
added destination scan testing and BoolT
9 years ago
ston1th
bb7e45acf1
Added destination scan support for flags
9 years ago
Jesse Szwedko
005b120d20
Add godoc comments to flag structs
9 years ago
Sergey Romanov
f47f7b7e85
Fix panic if Valus in Int/StringSliceFlasg is missing
9 years ago
jhowarth
a6482d2687
Merge remote-tracking branch 'upstream/master'
...
Conflicts:
app.go
command.go
flag.go
10 years ago
jszwedko
44d40054fa
Use 0 as the base when parsing ints
...
To be consistent with what the stdlib flag package does.
10 years ago
Sam Zaydel
ef23aa6da2
strconv.ParseInt should be used instead of strconv.ParseUint when reading Int Flags from envvars.
10 years ago
jszwedko
059c02782a
Use double quotes in output for defaults
...
Windows doesn't recognize 's for wrapping values. "s should work on all
systems.
10 years ago
Dan Buch
21d399c3fa
Merge pull request #166 from codegangsta/fix-generic-flag-help-text
...
Fix help text for generic flag to not insinuate that you can specify mul...
10 years ago
Dan Buch
5b9e204508
Merge pull request #153 from codegangsta/allow-hiding-of-help-flag
...
Allow hiding of help flag without hiding help subcommand
10 years ago
jszwedko
22dbe6ffdc
Fix help text for generic flag to not insinuate that you can specify multiple
...
Feels like it may have been copied from StringSliceFlag or something,
but update the output to be more consistent with other single value
flags.
Also added comments to the String and Apply functions.
10 years ago
Jesse Howarth and Michael Ivey
73e64a14fd
Add (required) to help of flags that are required.
10 years ago
Jesse Howarth and Michael Ivey
7e05320026
Implement required flags
10 years ago
jszwedko
780f839a02
Allow hiding of help flag without hiding help subcommand
...
By utilizing struct zero value
10 years ago
Dan Buch
78d497e4cf
Adding support for multiple env var "cascade"
10 years ago
Ghislain Gt
98af61a59f
Add time.Duration flag type
10 years ago
Dan Buch
fc16c67be3
Updating structs to use labels, adding tests for env stuff
10 years ago
Dan Buch
97fd93272f
Starting to hack in some env var configuration goodness
10 years ago
Jeremy Saenz
bb9189510a
Merge pull request #81 from zenoss/upstream/feature/generic-flags
...
Generic parsers as flag types
10 years ago
Summer Mousa
a911ec75e4
Can now change these default flags in other applications
11 years ago
Pekka Enberg
646b290d5d
Make StringSliceFlag usage text consistent
...
This fixes StringSliceFlag default usage text to be consistent with
IntegerSliceFlag.
Before:
-f [] `-f option -f option` port forwarding rules
After:
-f '-f option -f option' port forwarding rules
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
11 years ago
Summer Mousa
1eaa882c3a
removed extranneous value method on the generic type
11 years ago
Summer Mousa
13e88629f5
Generic parsers as flag types
11 years ago
Jeremy Saenz
640826c88f
Merge pull request #78 from zenoss/feature/bash-completion
...
Bash completion
11 years ago
Summer Mousa
3a10545f91
Made bash completion command optional; still need to update documentation
11 years ago
Ryan Schmukler
312151dca4
remove quotes for empty StringFlags
11 years ago