Commit Graph

26 Commits

Author SHA1 Message Date
Nick Miyake
19e54c4a2b Update error message for missing required flags (#580)
Make it so that first letter is not capitalized and rephrase
to remove "have/has".
2017-11-19 10:22:51 +01:00
Albert Nigmatzianov
d6a430541c Edit ResetFlags and ResetCommands descriptions 2017-11-09 07:56:43 +01:00
Albert Nigmatzianov
65c8acb228 Improve tests 2017-11-09 07:56:43 +01:00
Thomas Cyron
7b2c5ac9fc Create new buffer if not present yet (#549)
Fixes a nil dereference when TraverseChildren is used
with multiple subcommands.
2017-10-12 20:25:33 +02:00
Di Xu
7cd9cc6d44 add test for c.Name() if c.Use gets changed (#548) 2017-10-12 12:50:22 -04:00
Di Xu
4d6af280c7 enforce required flags (#502) 2017-10-09 23:44:33 -04:00
Daniel Nephin
83b1f03962 Add a TraverseChildren option to allow for flags on each command in the hierarchy (#299)
Fix #277 
Fix #467
2017-10-07 23:29:11 +02:00
Albert Nigmatzianov
8c6fa02d22 Fix InitDefaultHelpCmd when custom help command is set 2017-06-29 12:52:34 +02:00
Albert Nigmatzianov
99b5d838ca Show messages if deprecated flags are used
Fix #463
2017-06-19 23:05:29 +02:00
Albert Nigmatzianov
7d22e77cce Fix incorrect merge of pflag.CommandLine to cmd.Flags()
Fix #443
2017-05-12 20:22:26 +02:00
Albert Nigmatzianov
fe69f2e3a3 Make initHelpFlag public
Used for solving #424
2017-05-07 00:45:39 +02:00
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