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
Tyler Davis
530df59178
Pass context into handleExitCoder
7 years ago
Tyler Davis
9d61cbad02
Updated command.go to use App handleExitCoder
7 years ago
Jesse Szwedko
c64d74a5d9
Do not double print errors from Before()
...
They should be handled by HandleExitCoder() as `After()` errors are.
7 years ago
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.
7 years ago
Harshavardhana
f7d6a07f2d
Add support for custom help templates.
7 years ago
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
8 years ago
Jesse Szwedko
9913f0cef2
Merge branch 'master' into subcommand-structure
8 years ago
Joe Richey
e109e81e6a
Subcommand structure should be correctly copied to main structure
8 years ago
Robert Bittle
4ed366e201
Pass the ErrWriter on the root app to subcommands
8 years ago
Joe Richey
0083ae8732
Usage/Description/ArgsUsage correctly copied when using subcommand
8 years ago
Maximilian Meister
ac772237b9
command: enable ordering commands by name
8 years ago
Joshua Rubin
2da42640ad
Merge remote-tracking branch 'origin/master' into completion_fix
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
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
8 years ago
Joshua Rubin
ea3df26e64
make shell autocomplete more robust
8 years ago
Richard Kovacs
4cc2bad36e
Display error instead of just say command is incorrect
8 years ago
Shukui Yang
5d108a4435
bug fix when SkipFlagParsing is false and SkipArgReorder is true
...
Signed-off-by: Shukui Yang <yangshukui@huawei.com>
8 years ago
Frances Bar
3df4b71842
Backport no argument reordering as an option
...
In the unreleased version 2, the argument reordering has been removed
(in f585ec7cb8
) since it only worked if
all of the arguments appeared before all of the flags, but not if they
were intermixed which was of limited utility and caused some confusion.
This commit allows enabling of this future behavior via SkipArgReorder.
Ideally we'd support complete intermingling of flags and arguments, but
this is unlikely to happen until we switch flag parsers.
Fixes #515
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
5c641d69b4
Merge branch 'hidden_command' of https://github.com/psmit/cli into psmit-hidden_command
9 years ago
Dan Buch
fed78b8bab
Rework of hidden flag impl plus some Action func corrections
9 years ago
Dan Buch
e671f0b23b
Merge pull request #339 from jack230230/master
...
Add App.Metadata
9 years ago
王振威
f72d405107
Change Extras to Metadata
9 years ago
Dan Buch
d45f7c1fe2
Allow for legacy and newer Action func signatures
9 years ago
Dan Buch
f688d47415
Encapsulate ExitCoder check into a lil func
9 years ago
Dan Buch
b7329f4968
Switch from multi-return with exit codes to ExitCoder check
9 years ago
Dan Buch
a17c8cf1d8
Rename func type suffixes `Fn`->`Func` and add `OnUsageErrorFunc`
9 years ago
Dan Buch
10c8309d84
Merge branch 'develop' of https://github.com/txgruppi/cli into txgruppi-develop
9 years ago
Jesse Szwedko
042842b819
Remove CategorizedHelp from App and allow subcommands to have categories
...
Just place all subcommands in categories, the default category will be
"" which will properly format the output (and group commands that have
no category).
Also allow subcommands to have categories.
Lastly, augment the test to check the output.
9 years ago
Soulou
a0801792cc
Allow to sort commands by category
9 years ago
王振威
88ea7cbec8
Add App extras info
9 years ago
Uwe Dauernheim
a755a95d01
Fix semantic typo
9 years ago
Jesse Szwedko
d5f087da9d
Merge pull request #289 from KSubedi/master
...
Added command to have a custom text on the USAGE section of help
9 years ago
Gregor Noczinski
66c1742012
* Fixed typos
9 years ago
Gregor Noczinski
c462071a52
* Added ability to customize usage error messages
9 years ago
leonardyp
6f6e8caf6c
Repeat context statement because of a is a pointer
...
performance optimization
gofmt code
9 years ago
Andreas Kupries
bb4e78eb6a
Fixed mishandling of a "-"(dash)-argument causing reordering of cli non-flag arguments.
...
Added test demonstrating issue (PASS with fix, FAIL without).
9 years ago
Gregor Noczinski
f3c8e07836
Also show help if App/Command Before produces error.
9 years ago
Gregor Noczinski
f90cd56647
Handle Before and After of Command without handling it as subCommand if there is no subCommand.
9 years ago
Jesse Szwedko
6191d931b7
When skipping flag parsing, still parse into arguments
...
Fool the FlagSet into thinking that all arguments are actually
arguments rather than attempting to parse them as flags.
9 years ago
Jesse Szwedko
bc3cb33cef
Actually skip parsing of flags if SkipFlagParsing is set
...
Previous just skipped if firstFlagIndex was > -1
9 years ago
Nathan LeClaire
c538c376c9
Do not return error when flag parsing should be skipped
...
Signed-off-by: Nathan LeClaire <nathan.leclaire@gmail.com>
9 years ago
Kaushal Subedi
8b46886de8
added flag to have a custom text on the USAGE section of help
9 years ago
Tristan Zajonc
c7aac252f1
add tests
9 years ago
Tristan Zajonc
cc46ca1020
allow overriding help name
9 years ago
Tristan Zajonc
aced6e8739
fix tests
9 years ago
Tristan Zajonc
ecb0b5ac0a
improve help by including parent command for subcommands
9 years ago
Tristan Zajonc
ef65245544
add ArgsUsage to App and Command
9 years ago