Commit Graph

113 Commits

Author SHA1 Message Date
5fc8124af1
Merge branch 'master' into merging-jereksel-zsh 2018-02-24 21:58:26 -05:00
Alan D. Cabrera
1d334f10ce Add newline before command categories
The simple formatting change adds a nice blank line before each command
category.  Documentation in README.md is also updated to be more
accurate.
2017-09-08 10:43:30 -07:00
688c5a9d4f Merge branch 'master' into merging-jereksel-zsh 2017-08-03 14:38:20 -04:00
Jesse Szwedko
48db8e2435 Display UsageText on Commands and Subcommands
If it is set, otherwise build the usage.

Fixes #592
2017-06-24 20:02:36 -07:00
Jesse Szwedko
74811faef3 Merge branch 'master' into extra-info 2017-06-11 16:24:10 -07:00
Harshavardhana
dd3849a7e6 Add tests as requested. 2017-05-08 09:53:53 -07:00
Harshavardhana
baa33cb888 Add support for ExtraInfo. 2017-05-08 09:53:53 -07:00
Harshavardhana
f7d6a07f2d Add support for custom help templates. 2017-05-08 09:53:53 -07: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
Joe Richey
0083ae8732 Usage/Description/ArgsUsage correctly copied when using subcommand 2017-01-09 15:57:49 -08:00
7250c97913 Merge branch 'master' into merging-jereksel-zsh 2016-12-21 15:11:00 -05:00
Joshua Rubin
2da42640ad
Merge remote-tracking branch 'origin/master' into completion_fix 2016-11-18 09:28:39 -07:00
Joshua Rubin
8dd1962f7b
change "complete" to "shellComplete" 2016-11-14 09:35:22 -07: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
Joshua Rubin
ea3df26e64
make shell autocomplete more robust 2016-11-04 14:56:28 -06:00
W. Trevor King
3c2bce5807 help: Cleanup AppHelpTemplate trailing whitespace
Most of the changes here remove trailing whitespace, but I also add
code to select "AUTHOR" or "AUTHORS" as appropriate instead of the
previous "AUTHOR(S)".  The template for listing with an entry per line
is:

   {{range $index, $entry := pipeline}}{{if $index}}
   {{end}}{{$entry}}{{end}}

That range syntax is discussed in [1].

Also add a unit test, which tests both these whitespace changes and
also the earlier App.Description addition.

[1]: https://golang.org/pkg/text/template/#hdr-Variables
2016-10-22 16:02:21 -07:00
W. Trevor King
c4a46a7df2 app: Add App.Description
So you can describe what the application is for without requiring
users to drill down into a particular command.
2016-10-12 08:06:41 -07:00
Dan Buch
363d9c9a31
Add a hack so that zsh completion only runs for zsh 2016-07-24 17:29:13 -04:00
Andrzej Ressel
ceeebaba04 [PoC] Improve zsh autocompletions 2016-07-21 08:47:59 +02:00
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
2016-07-13 14:48:16 -07:00
James Cunningham
e97f74a570
fix ActionFunc signature of ShowAppHelp action 2016-06-07 16:28:10 +01:00
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).
2016-06-01 15:27:03 -07:00
Dan Buch
b9d96954ca
Fix command alias printing in help text
Closes #405
2016-05-10 13:41:43 -04:00
Matt Farina
2f110bd745 Cleaned up exported func comments per golint 2016-05-09 10:12:59 -04:00
Dan Buch
5a5fa990e1
Merge remote-tracking branch 'origin/master' into exit-nonzero-for-unknown-subcommand 2016-05-09 00:59:36 -04:00
Dan Buch
97d2df6dd7
Merge remote-tracking branch 'origin/master' into psmit-hidden_command 2016-05-08 18:44:38 -04:00
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
2016-05-07 17:26:15 -07: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
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.
2016-05-03 06:54:05 -04:00
Dan Buch
5c641d69b4
Merge branch 'hidden_command' of https://github.com/psmit/cli into psmit-hidden_command 2016-05-03 05:50:36 -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
Dan Buch
b7329f4968
Switch from multi-return with exit codes to ExitCoder check 2016-04-27 09:12:34 -04:00
Dan Buch
10c8309d84
Merge branch 'develop' of https://github.com/txgruppi/cli into txgruppi-develop 2016-04-25 18:10:10 -04:00
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
2016-03-26 15:39:47 -07:00
Radek Simko
d21170f0e3 Never show version if HideVersion=true 2016-03-21 16:12:46 +00:00
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.
2016-03-20 12:17:13 -07:00
Soulou
d0997e8f99 Set Categories as a read-only method and fix tests 2016-03-20 11:35:26 -07:00
Soulou
994a7028e2 Categories as slice, not a map anymore, order is always preserved 2016-03-20 11:35:25 -07:00
Soulou
a0801792cc Allow to sort commands by category 2016-03-20 11:32:58 -07:00
Jesse Szwedko
d5f087da9d Merge pull request #289 from KSubedi/master
Added command to have a custom text on the USAGE section of help
2016-02-06 13:12:10 -08:00
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
2016-01-20 14:51:55 -07:00
Kaushal Subedi
8b46886de8 added flag to have a custom text on the USAGE section of help 2015-10-24 23:37:21 -06:00
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
2015-10-18 17:02:23 -07:00
elij
db7af859d2 make help and version parsing use actual specified values
fixes #254
2015-10-13 15:20:36 -07:00
Tristan Zajonc
aced6e8739 fix tests 2015-08-12 21:43:14 -07:00
Tristan Zajonc
ecb0b5ac0a improve help by including parent command for subcommands 2015-08-12 20:00:07 -07:00
Tristan Zajonc
ef65245544 add ArgsUsage to App and Command 2015-08-12 20:00:07 -07:00
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
2015-07-28 20:10:08 +02:00