Di Xu
b5d8e8f46a
cache command name ( #390 )
2017-02-09 11:54:17 -05:00
Daniel Nephin
99600f6874
Add a tags field for user defined tags on a Command. ( #359 )
...
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-02-07 16:20:48 -05:00
Oleg Atamanenko
0f056af21f
Added godocs to public methods. ( #386 )
...
* Added godocs to public methods.
* Fix gofmt formatting.
2017-01-24 11:30:45 -05:00
bogem
011f19e8ec
Fix condition in HelpFunc
...
I think, it's more obvious, what does this method
2016-10-14 20:34:35 +02: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
bogem
5da98880f3
Edit documentation
2016-08-30 22:14:27 +05:00
bogem
6e17f4e2c5
Fix typos
2016-08-20 12:04:53 +05:00
Fabiano Franz
ded646f978
Restore Help() and Usage() for backwards compatibility
2016-07-20 12:02:56 -03:00
Fabiano Franz
d6bf4ef243
Don't expose Usage() and Help() - our interfaces are UsageFunc, HelpFunc and UsageString
2016-07-15 17:18:59 -03:00
Fabiano Franz
20217d8f5e
Expose OutOrStdout and OutOrStderr and don't make assumptions if output is not set
2016-07-15 17:18:47 -03:00
Fabiano Franz
77530f537e
Help command must use Stdout instead of Stderr
2016-07-06 12:51:57 -03: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
Eric Paris
c21ee9da52
Merge pull request #288 from eparis/flags-vs-commands
...
Do not display bash commands if local flag specified
2016-06-07 08:37:00 -04:00
Mark Bates
dc6e9ece6f
added a flag to disable flags
2016-06-03 20:25:52 -04:00
Eric Paris
7bf964e5b6
Do not show subcommands in bash completion if a local flag was specified
...
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'
2016-06-03 12:44:58 -04:00
Kevin Peng
6096009e8d
Fixed Small Comment Typo
...
small error in function description
2016-05-17 13:17:01 -04:00
John Schnake
e14e47b7a9
Issue #267 : Ensure hidden flags/subcommands do not change help
...
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.
2016-04-27 13:33:23 -04:00
Eric Paris
60267ae24d
Merge pull request #257 from sttts/sttts-noun-aliases
...
Add noun aliases
2016-04-02 09:29:34 -05:00
Dr. Stefan Schimanski
1a0a490d76
Remove plural handling and add aliases for nouns in completion
2016-04-02 12:39:19 +02:00
Ian Walter
a0bd6c17b3
Fixing golint warnings
...
* 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
2016-03-31 09:53:34 -04:00
Fabiano Franz
16b7ba55fb
Must only add "[flags]" to the end of usage if not yet present
2016-03-15 18:22:20 -03:00
Jonathan Reyna
1ef0913976
Use nil instead of len for arg check.
...
This honors the SetArgs() call
2016-02-08 17:04:25 -05:00
Sascha Holzleiter
2bd8a730ae
always show help if requested, even if SilenceErrors is enabled
2015-12-24 08:52:49 -05:00
Eric Paris
73665614cb
Merge pull request #197 from magiconair/issue-195-mousetrap-win-only
...
Issue #195 : Compile mousetrap only on Windows
2015-12-16 19:04:05 -05:00
Nan Xiao
d95d1b86bb
Update command.go
...
Fix typo in AddCommand method.
2015-12-16 16:14:10 +08:00
Frank Schroeder
193b182195
Issue #195 : Compile mousetrap only on Windows
...
* Create command_win.go and command_notwin.go for windows only code
* Move call to mousetrap hook into separate preExecHook() function
2015-11-24 01:52:16 +01:00
Austin Riendeau
3f605993a9
Creates the ExecuteC function while maintaining Execute signature
2015-11-17 13:01:58 -07:00
Austin Riendeau
5144a3aa19
add a flag to disable autogen tag in man and markdown generators
...
Inherits from parent commands all the way to root
2015-11-08 09:58:38 -05:00
Anthony Fok
e5762054c9
Limit the verbose test workaround to "cobra.test" only
...
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.
2015-11-07 23:21:50 -07:00
Austin Riendeau
62e859a9ed
fixes verbose tests by checking if the first arg belongs to cobra
2015-11-07 11:42:13 -07:00
James Bowes
871b0edae2
Ensure the usage command is printed only once
...
Reverse a swap in logic introduced in #169 that would cause the usage
output to be printed twice.
Fixes #171
2015-10-31 10:22:19 -03:00
Austin Riendeau
2244c3923a
[silence-errors]: adds comments around code
2015-10-26 17:42:06 -06:00
Austin Riendeau
4729b374ae
[silence-errors]: adds Silence Usage
2015-10-26 17:38:08 -06:00
Austin Riendeau
03aabcda72
adds inheritance for SilenceErrors
2015-10-25 21:17:39 -06:00
Austin Riendeau
f6e1a2df92
[silence-errors]: -m adds a way for errors to silenced down the stack
2015-10-25 19:58:53 -06:00
siddharthist
c4d6dbe059
Added documentation for ArgsLenAtDash
2015-10-13 15:41:57 -07:00
Viktor Stanchev
72ee37f33e
fix bug with PersistentPreRunE
2015-09-30 00:09:17 -07:00
Fabiano Franz
a83a172122
Improve suggestions - add explicit SuggestFor attribute
2015-09-25 12:07:38 -03:00
Fabiano Franz
3afa4db2c6
Improve suggestions - prefix will match
2015-09-25 11:41:47 -03:00
Eric Paris
edde52e321
Provide the length of Args when a -- is found in commandline
...
This allows a program to know what args came before the -- and what args
came after.
2015-09-16 12:31:41 -04:00
Eric Paris
6d70311770
Merge pull request #149 from fabianofranz/siblings
...
Allows command suggestions along with "unknown command" errors
2015-09-13 22:44:46 -05:00
Fabiano Franz
b4087da7eb
Allows command suggestions along with "unknown command" errors
2015-09-13 23:35:10 -03:00
Eric Paris
632e090805
If nothing after flags: sting print a newline
2015-09-12 00:21:31 -04:00
Eric Paris
eeec8e3ce3
Merge pull request #153 from eparis/remove-useless-assignment
...
UsageTemple: remove useless variable assignment
2015-09-11 18:00:59 -05:00
Eric Paris
d96b4f7741
Merge pull request #152 from eparis/no-newline-after-flags
...
No newline after Flags in usage
2015-09-11 18:00:50 -05:00
Eric Paris
1ac08d9d94
UsageTemple: remove useless variable assignment
2015-09-11 18:52:47 -04:00
Eric Paris
85bb343e9c
Merge pull request #151 from eparis/no-newline-without-short
...
No leading newline if Short and Long both unset
2015-09-11 17:46:37 -05:00
Eric Paris
8af2b2b89f
No newline after Flags in usage
...
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.
2015-09-11 18:45:28 -04:00