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
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
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).
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
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.
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.
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.
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
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
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
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.