This adds what I think needs to be done to support categories for flags
but we will see if that works. It also forces the scripts to use python2
since they blow up under python3 which is becoming the default python on
many linux systems.
Small fix to app_test as well so it conforms to the new Flag interface.
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).
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.
This has some benefits, but results in possibly less informative error
messaging; however, given that there are only two accepted types,
I think the error messaging is sufficient.
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
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.