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
The refactoring is required since completion is also supported for zsh
shell.
Refactoring details:
- flag generate-bash-completion -> generate-completion
- var EnableBashCompletion -> EnableShellCompletion
- var BashComplete -> ShellComplete
- var BashCompletionFlag -> GenerateCompletionFlag
- type BashCompleteFunc -> ShellCompleteFunc
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
This was introduced by #36, but only worked in the specific case of all
arguments being passed before all flags. If the user mixed them, they
ended up with odd parsing behavior where the arguments were reordered
(causing #103 and #355).
Given the tradeoffs I think we should remove support for flag
reordering.
Fixes#103Fixes#355
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.
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.
This fixes a regression introduced by #227. When looking up global flags by walking up the parent context's we need to consider the special case when we are starting at the very top and there is no parent context to start the traversal.
Fixes#252