Commit Graph

92 Commits

Author SHA1 Message Date
Robert Liebowitz
03153b9cf8 Allow combining short flags globally 2019-08-05 06:38:23 -04:00
Lynn Cyrin
7ce0af189e
remove unused code 2019-07-18 00:52:24 -07:00
Lynn Cyrin
32d84d8e87
copy update 2019-07-17 00:25:13 -07:00
Lynn Cyrin
6a2ae78373
backwards compatible RequiredFlag implementation 2019-07-11 21:53:10 -07:00
Lynn Cyrin
8a58b7e039
remove manual isRequired funcs 2019-07-11 20:47:47 -07:00
Lynn Cyrin
fa8187f2ce
reduce diff 2019-07-11 20:19:42 -07:00
Lynn Cyrin
ce1630141e
reduce diff??? 2019-07-11 20:18:52 -07:00
Lynn Cyrin
138dbaafec
Merge branch 'master' into required_flags 2019-07-11 20:07:55 -07:00
Olivier Mengué
d7555e1729 Fix unnecessary uses of Sprintf
- use strconv directly
- use concatenation for "%s%s"
2018-01-26 21:15:37 +01:00
Joshua Rubin
37b7abb1c4
dont clobber slices with envvar
Signed-off-by: Joshua Rubin <jrubin@zvelo.com>
2017-11-21 15:21:31 -07:00
Jacob McCann
f971fca2b2 Allow FilePath to take []string 2017-10-31 10:43:11 -05:00
Brad Rydzewski
18a556e192 fix FilePath documentation in README.md 2017-10-31 10:29:11 -05:00
Brad Rydzewski
21fcab0dee ability to load variable from file 2017-10-31 10:29:11 -05:00
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`.
2017-10-28 03:00:11 -04:00
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.
2017-09-18 00:00:27 -04:00
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).
2017-05-05 22:24:14 -07:00
Jesse Szwedko
d71794de19 Make ApplyWithError a public method on errorableFlag
Add to altsrc flags. Otherwise, flagSet() was bypassing altsrc's attempt
at shadowing.
2016-11-19 10:51:20 -08:00
drekar
4661a59b20 errorableFlag: scope result of type assertion. 2016-11-17 09:48:03 -10:00
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.
2016-11-13 14:59:35 -08:00
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.
2016-11-13 14:59:27 -08:00
Antonio Murdaca
c516bce8f1
flags: provide a type to sort flags
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-10-21 10:37:18 +02:00
Dan Buch
6185b8d8fd
Generate code for flag types and context accessors 2016-06-23 00:56:44 -04:00
Dan Buch
a0e694ed72
Add UintFlag, Uint64Flag types and supporting code 2016-06-16 11:13:32 -04:00
Dan Buch
537f5beb66
Tweaks to Int64Flag PR 2016-06-16 10:14:28 -04:00
Bruno França dos Reis
5c7cca7f16 Adding Int64Slice related stuff in flag.go and context.go, and related tests 2016-06-11 21:54:33 -07:00
Bruno França dos Reis
4962423cba Adding Int64Flag type and related tests 2016-06-11 15:22:07 -07:00
Dan Buch
7cd5bed6cb
Backporting flagValue func from v2 branch 2016-06-08 10:34:44 -04:00
Joshua Rubin
f621deee5a
fix panic getting visible flags 2016-06-08 04:27:57 -06:00
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.
2016-05-09 10:15:05 -04:00
Matt Farina
2f110bd745 Cleaned up exported func comments per golint 2016-05-09 10:12:59 -04:00
Matt Farina
6f0b442222 Update to ErrWriter and make available on app 2016-05-06 12:14:26 -04:00
Matt Farina
2a256d4c53 Provide a variable for writing output with a default of os.Stderr 2016-05-05 10:26:53 -04:00
Dan Buch
cd92adcb75
Further simplifying default flag stringer func 2016-05-02 19:58:16 -04:00
Dan Buch
6089d723a8
Use existing prefixedNames func 2016-05-02 19:52:39 -04:00
Dan Buch
69a8e25f3d
Make flag usage rendering more consistent; show default values 2016-05-02 19:42:08 -04:00
Dan Buch
23af5dd643
Rename flag stringer func bits for clarity, consistency 2016-05-02 13:07:57 -04:00
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
2016-05-02 13:05:21 -04:00
Dan Buch
fed78b8bab
Rework of hidden flag impl plus some Action func corrections 2016-05-01 08:36:17 -04:00
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.
2016-04-30 22:24:27 -04:00
Kevin Cantwell
13b7eedc13 Parses usage placeholders via back quotes. Resolves #333 2016-04-21 23:04:01 -04:00
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.
2016-02-09 09:36:13 -07:00
Gregor Noczinski
09e2c89597 * Changed the way how to return the result. Because of strange ci failure 2016-01-23 12:01:49 +01:00
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)
2016-01-22 15:08:27 +01:00
Jille Timmermans
f101a00018 Export cli.Flag.GetName (previously cli.Flag.getName) 2015-12-15 17:29:03 +00:00
ston1th
25ef368235 added destination scan testing and BoolT 2015-11-14 22:39:38 +01:00
ston1th
bb7e45acf1 Added destination scan support for flags 2015-11-14 20:01:15 +01:00
Jesse Szwedko
005b120d20 Add godoc comments to flag structs 2015-06-02 20:51:09 -07:00
Sergey Romanov
f47f7b7e85 Fix panic if Valus in Int/StringSliceFlasg is missing 2015-06-01 01:50:23 +05:00
jhowarth
a6482d2687 Merge remote-tracking branch 'upstream/master'
Conflicts:
	app.go
	command.go
	flag.go
2015-03-02 15:21:01 -08:00
jszwedko
44d40054fa Use 0 as the base when parsing ints
To be consistent with what the stdlib flag package does.
2015-01-09 13:10:42 -05:00