* Fix shellcheck
Before this change:
In - line 204:
declare -F $next_command >/dev/null && $next_command
^-- SC2086: Double quote to prevent globbing and word splitting.
--- FAIL: TestBashCompletions (0.34s)
bash_completions_test.go:138: shellcheck failed: exit status 1
* Avoid storing pointer to nil
Before this change, the new test fails with:
--- FAIL: TestSetOutput (0.00s)
command_test.go:198: expected setting output to nil to revert back to stdout, got <nil>
Docker (https://github.com/docker/docker) now
also uses Cobra for the CLI. A majority of the
commands have been migrated (still some left),
but adding it already :)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
If one ran a command like
./root --boolFlag subcmd1 subcmd2
Thing worked fine. The code recognized that --boolFlag followed by a
space meant the next word was not the argument to --boolFlag. But other
flag types with a NoOptDefValue (like a Count flag) would not ignore the
"argument". On a command like:
./root --countflag subcmd1 subcmd2
The processor, when looking for a subcommand, would first throw out the
`--countflag subcmd1` and then look for subcmd2 under root.
The fix is to ignore the next word after any NoOptDefVal flag, not just
boolean flags.
* bash_completions: cleanup for go vet
The gnarly block of string in the Fprint tripped up go vet and was not
easy to read.
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
* test: cleanup for go vet
Looks like copy'pasta and an unused variable
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
* the current GPL 2 and 3 templates are incorrect on two counts:
1. the headers make a reference to the Lesser GPL instead of the GPL
2. the texts are incomplete and truncated: including a partial GPL
is as good as not including it at all from a GPL standpoint.
* this patch corrects the header templates and also removes nice but
not needed templating of appName.
* it also ensure the full text of the GPL licenses. Both header and
texts are copied verbatim from these URLs (with a minor change:
backticks have been replaced with single quotes to work around
escaping limitations on golang raw strings that are
backtick-delimited and do not accept escaping):
https://www.gnu.org/licenses/gpl-3.0.txthttps://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
The default pflag error is to only print the bad flag. This enables an application
to include a usage message or other details about the error.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>