Andrzej Ressel
ceeebaba04
[PoC] Improve zsh autocompletions
8 years ago
Jesse Szwedko
65da20beab
Correctly show help message if `-h` is provided to subcommand
...
Currently, if an action is specified on a subcommand, it ignores the
`-h` and `--help` flags if passed to the subcommand, e.g.:
`foo bar -h`
would call the default action on `bar` rather than show the help
documentation.
Fixes #477
8 years ago
Dan Buch
d5abb165ee
Merge remote-tracking branch 'origin/master' into merging-from-v1
8 years ago
James Cunningham
e97f74a570
fix ActionFunc signature of ShowAppHelp action
8 years ago
Tianon Gravi
a121e978f7
Switch "printHelp" tabwriter padchar to space
...
Using tabs for alignment is troubling if the output is used for anything besides display in a terminal (or if the user's terminal allows for adjustment of the default tab size), as noted by the documentation for `tabwriter` (https://golang.org/pkg/text/tabwriter/#Writer.Init ):
> (for correct-looking results, tabwidth must correspond to the tab width in the viewer displaying the result)
The safer solution is to use `' '` as the `padchar`, which only carries the assumption of a fixed-width font (which is a more reasonable assumption than a fixed, constant tab size).
8 years ago
Dan Buch
3d75e9e711
Go with interfaces + private opaque types
...
rather than public types that wrap slices
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
81fcf706ea
Replace all "stringly typed" fields with slice equivalents
...
and alter the Flag interface accordingly
Closes #415
8 years ago
Dan Buch
bef835d455
Remove all Context.Global* methods
...
and change the behavior of the non-Global variants to always search up the
context lineage.
Closes #385
8 years ago
Dan Buch
b9d96954ca
Fix command alias printing in help text
...
Closes #405
8 years ago
Matt Farina
2f110bd745
Cleaned up exported func comments per golint
8 years ago
Dan Buch
5a5fa990e1
Merge remote-tracking branch 'origin/master' into exit-nonzero-for-unknown-subcommand
8 years ago
Dan Buch
97d2df6dd7
Merge remote-tracking branch 'origin/master' into psmit-hidden_command
8 years ago
Jesse Szwedko
592f1d97e5
Exit non-zero if a unknown subcommand is given
...
Currently it just prints the help message and exits 0.
We do this by modifying the helpCommand and helpSubcommand cli.Commands
to return an error if they are called with an unknown subcommand. This
propogates up to the app which exits with 3 and prints the error.
Thanks to @danslimmon for the initial approach!
Fixes #276
8 years ago
Matt Farina
6f0b442222
Update to ErrWriter and make available on app
9 years ago
Matt Farina
2a256d4c53
Provide a variable for writing output with a default of os.Stderr
9 years ago
Dan Buch
cc481d6b0e
Adjust command hiding to use similar convention as hidden flags
...
plus breaking out "setup" portion of `App.Run` into its own method, cleaning up
some bits of the help templates, and allowing for runtime opt-in of displaying
template errors to stderr.
9 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
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
b7329f4968
Switch from multi-return with exit codes to ExitCoder check
9 years ago
Dan Buch
10c8309d84
Merge branch 'develop' of https://github.com/txgruppi/cli into txgruppi-develop
9 years ago
Jesse Szwedko
bc465beccc
Merge pull request #346 from codegangsta/category_sort_2
...
Add option to make categories with command, to display a more structured help
9 years ago
Radek Simko
d21170f0e3
Never show version if HideVersion=true
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
d0997e8f99
Set Categories as a read-only method and fix tests
9 years ago
Soulou
994a7028e2
Categories as slice, not a map anymore, order is always preserved
9 years ago
Soulou
a0801792cc
Allow to sort commands by category
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
Matt Butcher
54b6cca78e
Remove panic from help.
...
There is a panic in printHelp that can be trivially triggered when the
shell closes os.Stdout. This happens, for example, when data is piped
between a cli app and something else.
See https://github.com/helm/helm/issues/387
9 years ago
Kaushal Subedi
8b46886de8
added flag to have a custom text on the USAGE section of help
9 years ago
Ryan Graham
732e97aee8
only display app version and help message once
...
When processing the flags for -h/--help and -v/--version, only check
the flags in checkVersion() and checkHelp() instead of also printing
the associated message.
This fixes the problem of `app -h` and `app -v` printing their output
twice. The doubling was caused by printing the message once for each
registred alias for the given flags (-h/--help and -v/--version).
Resolves #285
9 years ago
elij
db7af859d2
make help and version parsing use actual specified values
...
fixes #254
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
Tarcísio Gruppi
49c1229409
Added exit code support
...
Now the exit code can be returned by BeforeFn, ActionFn and AfterFn.
The `os.Exit` function is not called by this packaged
This closes #66 and closes #164
9 years ago
Brian Goff
758ad1e836
Sets a subcommand's parent cmd
...
This allows the help output to show the correct/full command path to the
subcommand.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
9 years ago
Martin Falatic
8cae4991af
Fixing more formatting
9 years ago
Martin Falatic
4d3820c145
If there are no commands, don't show Commands section. Also fixed Copyright section formatting.
9 years ago
Martin Falatic
595c055010
If Version is an empty string, suppress version output in usage help.
9 years ago
Jesse Szwedko
7ad88c2740
Merge pull request #238 from polds/copyright
...
Add the ability to add a copyright
9 years ago
Peter Olds
4a11a6ba05
Remove whitespace #238
...
Signed-off-by: Peter Olds <polds@kyanicorp.com>
9 years ago
Peter Olds
2726643347
Add the ability to add a copyright
...
Signed-off-by: Peter Olds <polds@kyanicorp.com>
9 years ago
Jesse Szwedko
2272dad83e
Version and help check should look for local flags too
...
Now that Global looks up the chain of contexts, the top level should
access the flags without the prefix (i.e. Bool rather than GlobalBool).
9 years ago
Victor Vieux
7c041f5811
do not print 'AUTHOR(S):' is there is no author
...
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
10 years ago
jszwedko
e842547421
Readd printHelp function back
...
But update signature to take a writer. This is a backwards incompatible
change for those overriding the HelpPrinter, but the hope is that this
feature is largely unused and the usage is easily updated.
10 years ago
Dan Buch
2bcd11f863
Merge pull request #193 from codegangsta/add-aliases
...
Add `Command.Aliases` and deprecate `Command.ShortName`
10 years ago
陈小玉
84630daaf4
Update help.go
...
change template `AUTHOR(s)` tab ident to whitespace.
10 years ago
jszwedko
bf65971a6a
Add `Command.Aliases` and deprecate `Command.ShortName`
...
`Aliases` will be more flexible while still allowing "ShortName"
behaviour via `Aliases`.
10 years ago
Jesse Szwedko
3e0905345c
Merge pull request #186 from nrdufour/master
...
Fixing the issue with a command with subcommands not showing help message
10 years ago
Nicolas Dufour
4be878bffc
Fixing the issue with a command with subcommands not showing help message.
...
- the command name is "" and HasName was returning true for an empty
ShortName.
- the Show method wasn't aware that command name was just "" and
returned the first subcommand.
10 years ago
Harrison
c6592bb487
app, help: add backwards compatibility for Authors
10 years ago
Peter Smit
5308b4cd0f
Allow commands to be hidden from help and autocomplete
10 years ago
Harrison
3d7183307a
app, help: add support for multiple authors
10 years ago
Dan Buch
a14c5b47c7
Merge pull request #154 from codegangsta/allow-writer-to-be-set
...
Allow writer to be set
10 years ago
Jesse Szwedko
e7849f9239
Merge pull request #128 from nbjahan/patch-1
...
Fixed ShowSubcommandHelp
10 years ago
jszwedko
e72094e6a4
Prefer fmt.Fprint* functions over io.WriteString
...
Less composition needed.
10 years ago
jszwedko
b8c8282de5
Merge remote-tracking branch 'origin/master' into allow-writer-to-be-set
...
Conflicts:
app.go
help.go
10 years ago
jszwedko
0d4870d63e
Rename Stdout -> Writer
10 years ago
pivaldi
59ef9567ae
Fix bash completion for deep level subcommands
10 years ago
Nima Jahanshahi
4db56687fa
Fixed ShowSubcommandHelp
...
ShowSubcommandHelp should show help for the subcommand not the app
10 years ago
Josh Mervine
120f0688a4
Merge remote-tracking branch 'parent/master'
...
Conflicts:
cli_test.go
flag_test.go
10 years ago
Jeremy Saenz
ec11175ac1
Merge pull request #123 from AudriusButkevicius/help
...
Additional help cleanup
10 years ago
Audrius Butkevicius
527fbe0671
Unify template formatting
10 years ago
Audrius Butkevicius
fcc1613bb5
Do not show empty description section
10 years ago
Audrius Butkevicius
e38bac8225
Print author
10 years ago
Audrius Butkevicius
bc02933ea4
Fix Subcommand help text
10 years ago
Audrius Butkevicius
d6d4e6448b
Hide "Options" sections in help, if no flags are defined
10 years ago
Joshua Mervine
5821632000
Adding VersionPrinter and tests.
10 years ago
John Hopper
60e3dcaf6d
Allow a writer to be set that represents Stdout so that redirection of App output may occur.
10 years ago
Jack Christensen
357921b483
Use HelpPrinter in ShowCommandHelp
11 years ago
Jeremy Saenz
5e1cde20d3
Merge pull request #75 from Winslett/command-not-found
...
Customizable command not found function
11 years ago
Summer Mousa
705994c2c6
Added unit tests
11 years ago
Summer Mousa
13f0c8c0f6
More consistent implementation of recursive subcommands
11 years ago
Summer Mousa
3a10545f91
Made bash completion command optional; still need to update documentation
11 years ago
Summer Mousa
0b29bee364
merging code
11 years ago
Chris Winslett
37299d4e5a
Customizable command not found function
11 years ago
Tim Jarratt
58bfabca6d
Add a way to override the app help printer
...
Fixes #64
11 years ago
Alexander Rødseth
22a56266c5
Removed the function and data structure for generating man pages
11 years ago
Alexander Rødseth
1bea6dcbf0
Custom type for arguments
11 years ago
Alexander Rødseth
7050f048d1
Added simple man page support
11 years ago
Jeremy Saenz
b25b7a883c
JMS #39 : Removed all calls to os.Exit().
11 years ago
Jeremy Saenz
8cea424806
JMS #28 : -h flags for subcommands
11 years ago
Jeremy Saenz
70eacca641
JMS #25 : Added support for help flags
11 years ago
Jeremy Saenz
41dde0adab
JMS #5 : Displaying help for subcommands. Better looking help code
11 years ago
Jeremy Saenz
0dd327f6e5
JMS #5 : Starting support for subcommand docs
11 years ago
Jeremy Saenz
d8cf49f0dd
Printing out version numbers
11 years ago
Jeremy Saenz
580cc011fd
JMS #14 : More help cleanup
11 years ago
Jeremy Saenz
63b9f2823a
JMS #14 : Improved help. Brought help commadn back to commands
11 years ago
Jeremy Saenz
6664835bc1
JMS #14 : Moving toward having and app object
11 years ago
Jeremy Saenz
3b0fc03a67
JMS #4 : Support for flag handling on command line
11 years ago
Jeremy Saenz
96f806fd22
JMS #3 : Passing a context struct instead of a string
11 years ago
Jeremy Saenz
921da63e2e
Support for global flags in help text
11 years ago
Jeremy Saenz
16bf6d4f76
Formatting
11 years ago
Jeremy Saenz
5a624affb8
Yo dawg, I heard you liked the help command...
...
So I described the help command in your help command
so you can help command while you help command
11 years ago
Jeremy Saenz
bdb9c5ab61
Support for shortnames
11 years ago
Jeremy Saenz
9186f6e81a
Removed error handling and cleaned up template
11 years ago
Jeremy Saenz
5b788be8a6
Formatted help text via templates
11 years ago
Jeremy Saenz
6016cafda3
Removed application object, help formatting
11 years ago