Commit Graph

140 Commits

Author SHA1 Message Date
Lynn Cyrin
64d3555482 trim whitespace 2019-10-01 20:21:12 -07:00
Lynn Cyrin
be0cc4b871 add a check 2019-10-01 20:18:53 -07:00
Lynn Cyrin
51259808ff better leading dash handling 2019-10-01 20:13:04 -07:00
Lynn Cyrin (they/them)
41eb645fa2
Merge branch 'master' into pass-through-regression 2019-09-15 11:57:12 -07:00
Lynn Cyrin (they/them)
72c249389c
Update command.go 2019-09-13 07:35:16 -07:00
Lynn Cyrin (they/them)
3f6f97754a
Update command.go
Co-Authored-By: Sascha Grunert <sgrunert@suse.com>
2019-09-13 07:27:16 -07:00
Robert Liebowitz
06e3d38d88 Avoid panic for missing flag value
Currently, in cases where a flag value is required but not passed and
short-option handling is enabled, a panic will occur due to a nil
pointer dereference. This prevents that situation from occurring,
instead propagating the appropriate error.
2019-09-13 06:11:09 -04:00
Lynn Cyrin
bfdd794eb3
docs 2019-09-11 23:05:26 -07:00
Lynn Cyrin
6da413ad82
fix go version support? 2019-09-11 22:45:51 -07:00
Lynn Cyrin
09cdbbfe28
more docs 2019-09-11 20:29:31 -07:00
Lynn Cyrin
10682fbde6
docs 2019-09-11 20:28:48 -07:00
Lynn Cyrin
49dbeed687
handle = input 2019-09-11 20:24:42 -07:00
Lynn Cyrin
7d0751fa13
add argIsFlag check 2019-09-11 19:25:51 -07:00
Lynn Cyrin
2071bcfb83
checkpoint 2019-08-26 00:18:36 -07:00
Lynn Cyrin
406a1c31b0
update vars and args 2019-08-25 14:12:13 -07:00
FaranIdo
08c24e22ed add missing ExitErrHandler in command + matching test, fixing #816 2019-08-12 00:29:46 +03:00
Ajitem Sahasrabuddhe
aed704a9d0
Merge branch 'master' into lint-fixes 2019-08-08 14:44:02 +05:30
Ajitem Sahasrabuddhe
fdba7e0f8c
linter fixes
code cleanup
changing some test code to ensure uniformity
2019-08-07 20:14:50 +05:30
Robert Liebowitz
03153b9cf8 Allow combining short flags globally 2019-08-05 06:38:23 -04:00
Lynn Cyrin
f4128a02f3
Update command.go 2019-08-01 22:54:15 -07:00
Lynn Cyrin
38f9e1622d
add environment variable support 🎉 2019-08-01 22:52:21 -07:00
Lynn Cyrin
f21b22dd90
cleanup some issues with error display 2019-08-01 22:10:18 -07:00
Lynn Cyrin
9438aba3b8
remove showFlagError, we can use the help printer assertion to accomplish the same goal 2019-08-01 19:54:57 -07:00
Lynn Cyrin
23f09ac1e8
cleanup tests, check required flags in more places 2019-07-28 22:19:35 -07:00
Lynn Cyrin
3d2d6975b4
reduce diff 2019-07-11 20:32:42 -07:00
Lynn Cyrin
0608059cc7
reduce diff 2019-07-11 20:32:15 -07:00
Lynn Cyrin
138dbaafec
Merge branch 'master' into required_flags 2019-07-11 20:07:55 -07:00
Gábor Lipták
9587fc27bd
Correct typo 2018-10-18 20:56:13 -04:00
Valentin Rothberg
c23dfba701 short opt handling: fix parsing
Only split a given string (e.g., "-abc") into short options (e.g., "-a",
"-b", "-c") if all those are flags.  To further avoid mistakenly
transform common arguments, catch "flag provided but not defined" errors
to iteratively transform short options.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>
Fixes: https://github.com/projectatomic/libpod/issues/714
2018-08-20 12:35:43 +02:00
Nico Windler
3a87b13b01 Fix args reordering when bool flags are present 2018-02-10 14:00:34 +01:00
Jesse Szwedko
e38e4ae2d0 Fix regression of SkipFlagParsing behavior
Introduced by df562bf1a8

Was mistakenly prepending the command name.
2017-12-29 13:38:18 -05:00
Jesse Szwedko
df562bf1a8 Refactor flag handling logic
Refactor logic introduced by #686
2017-12-03 13:38:50 -08:00
baude
ceaac7c915 Handle ShortOptions and SkipArgReorder
There was a bug in parsing when both ShortOptions
and SkipArgReorder were being used together.

Signed-off-by: baude <bbaude@redhat.com>
2017-11-29 09:22:26 -06:00
baude
fd5382e7a5 Combine bool short names
Adds the ability to allow the combination of bool
short-name options.  For example,

cmd foobar -ov

This is done through a bool "UseShortOptionHandler" set in
the command struct.

Built upon PR #621

Signed-off-by: baude <bbaude@redhat.com>
2017-11-13 16:29:20 -06:00
zhuchensong
43c8c02cf5 Support POSIX-style short flag combining 2017-11-08 16:05:47 -06: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
Tyler Davis
530df59178 Pass context into handleExitCoder 2017-06-28 09:52:12 -07:00
Tyler Davis
9d61cbad02 Updated command.go to use App handleExitCoder 2017-06-28 09:41:08 -07:00
Jesse Szwedko
c64d74a5d9 Do not double print errors from Before()
They should be handled by HandleExitCoder() as `After()` errors are.
2017-06-24 19:57:19 -07:00
Joe Richey joerichey@google.com
291122b8f0 Subcommand OnUsageError should be passed to app
Not all of the Command components were being passed to the created App
in the startApp function.
2017-06-21 17:55:49 -07:00
Harshavardhana
f7d6a07f2d Add support for custom help templates. 2017-05-08 09:53:53 -07:00
Jesse Szwedko
87fe13079e Rely on Command context in Run()
Was previously relying on the parent context which caused things like
`.Command` to not be available to OnUsageError().

Fixes #609
2017-04-24 15:19:34 -07:00
Jesse Szwedko
9913f0cef2 Merge branch 'master' into subcommand-structure 2017-01-28 13:35:02 -08:00
Joe Richey
e109e81e6a Subcommand structure should be correctly copied to main structure 2017-01-23 10:36:28 -08:00
Robert Bittle
4ed366e201
Pass the ErrWriter on the root app to subcommands 2017-01-18 23:29:26 -05:00
Joe Richey
0083ae8732 Usage/Description/ArgsUsage correctly copied when using subcommand 2017-01-09 15:57:49 -08:00
Maximilian Meister
ac772237b9
command: enable ordering commands by name 2017-01-09 16:40:32 +01:00
Joshua Rubin
2da42640ad
Merge remote-tracking branch 'origin/master' into completion_fix 2016-11-18 09:28:39 -07: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
0113f56d10 If no action is specified on the command or app, print the help documentation
Rather than panic'ing or displaying an opaque error message about the
signature which is more confusing to the end user.

Fixes #562
2016-11-12 13:37:07 -08:00