Commit graph

65 commits

Author SHA1 Message Date
Albert Nigmatzianov d20925b932 cmd: Small correctives 2017-05-05 10:35:27 +02:00
Albert Nigmatzianov ea3c5beeff Add TestHelpFlagInHelp 2017-04-26 21:24:14 +02:00
Albert Nigmatzianov f58a8d6bd3 Add TestSortedFlags 2017-04-20 15:38:50 +02:00
Tamir Duberstein 7aeaa2cce6 Avoid storing pointer to nil (#411)
* 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>
2017-04-02 10:14:34 -04:00
Ben Gadbois 6e91dded25 Make gofmt -s pass (#355) 2016-10-25 18:28:26 -07:00
Eric Paris ec2fe78599 Merge pull request #286 from dnephin/merge_flags_before_adding_help
Merge persistent flags before checking for a help flag
2016-10-10 11:14:18 -04:00
Daniel Nephin 67feb8173c Add support for setting a function to handle flag parsing errors.
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>
2016-10-10 10:56:48 -04:00
Chris Broadfoot d1371ecdb4 gofmt, govet, run those in Travis, add 1.7 2016-08-23 13:30:43 -07:00
Daniel Nephin 7faa7fcdd2 Merge persistent flags before checking for a help flag.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2016-06-20 14:58:44 -04:00
Andrey Kurilin ab97c7a63a Sort commands by their names
The slice of commands are sorted now automatically while Commands are called.
To turn off this feature, EnableCommandSorting variable is added.
2016-06-15 17:27:34 +03:00
Mark Bates dc6e9ece6f added a flag to disable flags 2016-06-03 20:25:52 -04:00
Steve Domino 6d2f1d2fa7 Ability to hide commands from usage/help text
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
2015-09-08 17:01:13 -06:00
Jeff Lowdermilk 79bd93d369 Add test for persistent bool flag on subcommand 2015-03-23 14:42:59 -07:00
Brendan Burns 93278e2f35 Add mergePersistentFlags in strip flags since we now look at the flag set. 2015-03-16 16:15:32 -07:00
Brendan Burns bbdea35c49 Fix stripFlags to be more intelligent about what it parses. 2015-03-12 22:36:49 -04:00