If a user specifies a flag to a command which doesn't make sense to a
subcommand do not show subcommands as a suggestion.
This also changes things to show both 'required flags' and 'commands'
instead of only 'required flags'
If a command has one flag which is hidden, it should not, for
instance, show the `Flags: ` heading. Likewise there are other
items in the help template which should respect hidden/deprecated
state.
* Moving final return outside of if-else
* Removing type declarations that Go can infer from values
* Cleaning up some existing comments
* Changing snake_case variables to camelCase
so that full path to the executable or a renamed executable
parses command-line arguments correctly as before.
Special thanks to @apriendeau for discovering "go test -v" failing
and for providing the initial workaround, see #155 and subsequent
discussions.
The flags usage template from pflags has a trailing \n. We need to
include a newline in case there are no flags in our template. This will
trim the newline from the end of the flags from pflag and we can do it
right outselves.
This slightly changes IsAvailableCommand in that a non-runnable command
with a runnable subcommand is now 'Available'
We also use IsAvailableCommand in the rest of the codebase instead of
half kinda sorta doing it incorrectly other places.
Added the ability to have hidden commands that cobra will still run as intended, however they won't show up in any usage/help text
adding internal field to command
private is a better name
hiding private commands in default help/usage
opting for 'hidden' over 'private'
updating all 'help command' checks to exclude hidden commands
updating how commands are displayed in usage/help text by updating/adding some methods. added tests for hidden/deprecated commands
making command hidden when testing hidden command execution
test now leverage the included suite and are much less custom. also removed deprecation tests, once I discovered them in cobra_test.go
updating hidden command test to be more reliable
removing unnecessary () when checking len(c.Deprecated)
updating command comments to be godoc friendly
We were just calling Help() when a user set the --help flag. You could
overwrite how the help subcommand worked with SetHelpFunc, but not now
the --help flag worked.
Today the HelpFunc() seemed to be tailor built for the `help`
subcommand. Which has a rather weird purpose as its `Run` needs to
find the actual command we want to get help about.
Instead make the HelpFunc() for a command be about that command,
rather than having it search for some other command...