Eric Paris
1a618fb24b
Do not add a space after a single flag completion ( #625 )
2018-02-21 07:50:56 -08:00
Eric Paris
b787445794
Use func (c *Command) consistently ( #530 )
...
It makes the docs looks better. The idea was suggested by @SamWhited
2017-09-05 13:20:51 -04:00
Eric Paris
d89c499964
Allow commands to explicitly state if they do, or do not take arbitrary arguments
...
Check that arguments are in ValidArgs
If a command defined cmd.ValidArgs check that the argument is actually
in ValidArgs and fail if it is not.
2017-07-23 09:57:27 +02:00
Eric Paris
347767f8bd
Partial revert of 4d2c4af 'Improve template mechanism' ( #439 )
...
There were template functions which we defined and others started using.
Although we no longer want those functions, since others use them,
deleting them breaks our API. Putting those (unused) functions back.
2017-05-09 15:07:05 -04:00
Eric Paris
92ea23a837
Fix subcommand locations with NoOptDefValue flags ( #391 )
...
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.
2017-02-23 08:12:51 -05:00
Eric Paris
856b96dcb4
Merge pull request #353 from bogem/helpfunc
...
Fix condition in HelpFunc
2016-10-14 18:20:36 -04: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
Eric Paris
b620a7591d
Merge pull request #283 from dnephin/add_flag_usage_func
...
Add support for setting a function to handle flag parsing errors
2016-10-10 11:13:51 -04:00
Eric Paris
9c28e4bbd7
Merge pull request #339 from bogem/fixes
...
Some fixes
2016-08-30 13:49:25 -04:00
Eric Paris
d671d98363
Merge pull request #338 from icaoweiwei/patch-2016-08-29-2
...
Fix typo
2016-08-30 11:26:59 -04:00
Eric Paris
37c3f80603
Merge pull request #332 from broady/master
...
travis: fix build matrix config
2016-08-23 17:51:50 -04:00
Eric Paris
8e9c5e77eb
Merge pull request #331 from broady/fmtetc
...
gofmt, govet, run those in Travis
2016-08-23 16:37:01 -04:00
Eric Paris
1f4717172e
Merge pull request #327 from bogem/fixes
...
Some small fixes
2016-08-22 09:59:44 -04:00
Eric Paris
7c674d9e72
Merge pull request #313 from euank/swift-as-a-cobra-hidden-as-a-ninja
...
Display neither hidden nor deprecated flags in bash completion
2016-08-02 18:37:37 -04:00
Eric Paris
f62e98d28a
Merge pull request #300 from cshung/master
...
Include instruction for building the cobra tool in README.md
2016-07-22 04:15:47 -04:00
Eric Paris
dbb7c2d02e
Merge pull request #308 from fabianofranz/restore_backwards_compatibility
...
Restore Help() and Usage() for backwards compatibility
2016-07-20 22:00:57 -04:00
Eric Paris
b24564e919
Merge pull request #305 from fabianofranz/expose_out
...
Fixes how we expose help and usage and expose output without making assumptions
2016-07-15 19:55:49 -04:00
Eric Paris
a272c3cbd5
Merge pull request #303 from fabianofranz/testing_help_exiting_1
...
Help command must use Stdout instead of Stderr
2016-07-08 16:24:02 -04:00
Eric Paris
6a8bd97bdb
Merge pull request #294 from dnephin/fix_man_page_gen_bugs
...
Fix man page gen bugs
2016-06-21 16:47:55 -04:00
Eric Paris
bc81c21bd0
Merge pull request #293 from andreykurilin/sort_commands
...
Sort commands by their names
2016-06-15 10:36:14 -04:00
Eric Paris
1238ba19d2
Merge pull request #290 from joe2far/patch-1
...
Fixed typos in README and docstring
2016-06-07 08:43:46 -04: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
Eric Paris
f447048345
Merge pull request #289 from markbates/disable-flags
...
added a flag to disable flags
2016-06-04 00:47:32 -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
Eric Paris
ecc7ea6969
Show both commands and 'required flags' instead of only 'required flags'
2016-06-03 12:44:54 -04:00
Eric Paris
a5f153e19b
add vim to gitignore
2016-06-03 10:18:59 -04:00
Eric Paris
f368244301
Merge pull request #278 from kevintpeng/patch-1
...
Fixed Small Comment Typo
2016-05-17 13:19:29 -04:00
Eric Paris
4c05eb1145
Merge pull request #265 from sttts/sttts-shellcheck
...
Run shellcheck on bash completion
2016-04-03 09:08:35 -05:00
Eric Paris
60267ae24d
Merge pull request #257 from sttts/sttts-noun-aliases
...
Add noun aliases
2016-04-02 09:29:34 -05:00
Eric Paris
2ccf9e982a
Merge pull request #264 from kkirsche/patch-1
...
Update template per to match previous pr with golint fix
2016-04-01 21:14:51 -05:00
Eric Paris
b0d571e7d5
Merge pull request #260 from ianwalter/code-cleanup
...
Fixing golint warnings
2016-03-31 09:32:10 -05:00
Eric Paris
ee150b4fa2
Merge pull request #258 from kkirsche/patch-1
...
Update root.go to fix golint bug with comment
2016-03-30 16:59:46 -05:00
Eric Paris
c678ff029e
Merge pull request #256 from sttts/sttts-fix-bash-escaping
...
Fix escaping of % in bash code strings
2016-03-22 12:10:42 -05:00
Eric Paris
966e6048eb
Merge pull request #230 from garthk/fix-man-see-also
...
Ensure SEE ALSO list has no leading comma.
2016-03-21 19:23:55 -05:00
Eric Paris
57021c6b4d
Merge pull request #244 from apriendeau/silence-errors-readme
...
updates readme to Explain SilenceErrors and SilenceUsage #225
2016-03-21 19:22:44 -05:00
Eric Paris
d6b481239e
Merge pull request #255 from sttts/sttts-bash-completion-flag-equal
...
Advanced custom bash completion of flags
2016-03-21 19:22:24 -05:00
Eric Paris
1bacefc9a2
Merge pull request #254 from fabianofranz/optional_options_at_the_end_of_usage
...
Must only add "[flags]" to the end of usage if not yet present
2016-03-15 16:50:08 -05:00
Eric Paris
04d02e3184
Merge pull request #241 from bogem/typo
...
Fix typo in README
2016-02-06 12:39:43 -05:00
Eric Paris
8e91712f17
Merge pull request #228 from garthk/fix-doc-generation
...
Fix doc generation and its documentation
2016-01-16 22:09:38 -05:00
Eric Paris
9c93009019
Merge pull request #223 from mattnenterprise/doc-link-fixes
...
Fix links to markdown and man page docs
2016-01-13 22:06:19 -05:00
Eric Paris
a3a9f345ca
Merge pull request #218 from mvdan/error-checking
...
Error checking for doc generation
2016-01-06 09:57:15 -05:00
Eric Paris
c82a0ceef8
Merge pull request #215 from mvdan/interfacer
...
Replace *bytes.Buffer with io.Writer
2016-01-05 16:50:52 -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
Eric Paris
11265d64db
Merge pull request #210 from boz/colon-completion
...
Bash completion for names with ':' character.
2015-12-16 17:12:45 -05:00
Eric Paris
ea3bf167cf
Merge pull request #211 from NanXiao/patch-1
...
Update command.go
2015-12-16 10:02:01 -05:00
Eric Paris
29cddf65b2
Merge pull request #208 from gosharplite/patch-2
...
Update four to three
2015-12-09 08:50:41 -05:00
Eric Paris
8210022f43
Merge pull request #207 from gosharplite/patch-1
...
Fix wrong command name.
2015-12-08 10:13:42 -05:00
Eric Paris
1c44ec8d3f
Merge pull request #200 from sobit/patch-1
...
fix typo
2015-11-24 10:32:17 -05:00
Eric Paris
cb63a06ed9
Merge pull request #192 from apriendeau/executeC
...
Creates the ExecuteC function while maintaining Execute signature
2015-11-18 17:09:54 -05:00
Eric Paris
2e6a428921
Merge pull request #179 from eparis/init_comp
...
Check for _init_completion not_init_completionS
2015-11-03 15:41:40 -05:00
Eric Paris
57c62d3180
Merge pull request #173 from jojomi/master
...
Update README.md
2015-11-03 15:29:33 -05:00
Eric Paris
9199ed1e52
Merge pull request #178 from mattnenterprise/completions-osx
...
Modifying bash completions so they can run on OSX
2015-11-03 15:28:50 -05:00
Eric Paris
58e38f95da
Check for _init_completion not_init_completionS
2015-11-03 15:09:37 -05:00
Eric Paris
a082ce41f3
Merge pull request #174 from jbowes/fix-duplicate-usage
...
Ensure the usage command is printed only once
2015-11-02 14:27:52 -05:00
Eric Paris
24562666ea
Merge pull request #172 from tamird/patch-1
...
README: fix CockroachDB typo
2015-10-29 15:18:41 -05:00
Eric Paris
230787ee13
Merge pull request #169 from apriendeau/silence-errors
...
[silence-errors]: adds a way for errors to silenced down the stack
2015-10-26 19:12:39 -05:00
Eric Paris
8b2293c741
Merge pull request #167 from siddharthist/docs/ArgsLenAtDash
...
Added documentation for ArgsLenAtDash
2015-10-13 17:51:39 -05:00
Eric Paris
d732ab3a34
Merge pull request #164 from vikstrous/fix_bug
...
fix bug with PersistentPreRunE
2015-09-30 09:31:26 -04:00
Eric Paris
046a673252
Merge pull request #163 from fabianofranz/siblings_improvements
...
Improve suggestions
2015-09-29 11:27:22 -04:00
Eric Paris
53d96508f5
Merge pull request #160 from eparis/len-at-dash
...
Provide the length of Args when a -- is found in commandline
2015-09-17 16:09:08 -05: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
4b76e97cd6
Merge pull request #158 from eparis/more-errors-in-test
...
More error output if a could of _test fail
2015-09-15 22:57:41 -05:00
Eric Paris
664a3ab4a3
Merge pull request #159 from eparis/travis
...
Update travis to use more versions of go
2015-09-15 22:57:29 -05:00
Eric Paris
6e4e76655d
More error output if a could of _test fail
2015-09-15 18:02:03 -04:00
Eric Paris
79996f7fcf
Update travis to use more versions of go
2015-09-15 18:01:43 -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
Eric Paris
b28774dd68
Merge pull request #154 from eparis/fix-trailing-newline
...
If nothing after flags: sting print a newline
2015-09-11 23:27:51 -05: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
0d9b07baf9
Merge pull request #150 from eparis/help-not-available
...
Do not count "help" as "Available"
2015-09-11 17:46:27 -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
Eric Paris
717619095e
No leading newline if Short and Long both unset
...
Before --help would start
```
Usage:
command [flags]
[...]
```
After --help will show
```
Usage:
command [flags]
[...]
```
2015-09-11 18:28:40 -04:00
Eric Paris
24b4b01ffa
Do not cound "help" as "Available"
2015-09-11 18:25:28 -04:00
Eric Paris
42498ec777
Merge pull request #148 from tamird/trailing-spaces
...
trim trailing whitespace
2015-09-11 17:24:06 -05:00
Eric Paris
4b86c66ef2
Merge pull request #146 from eparis/is-available-rework
...
Update IsAvailableCommand checks
2015-09-09 14:20:07 -05:00
Eric Paris
3eac1434ef
Update IsAvailableCommand checks
...
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.
2015-09-08 22:48:12 -04:00
Eric Paris
75d96d75c3
Merge pull request #145 from eparis/man-cleanups
...
Enhance Man Page Generation
2015-09-08 18:19:27 -05:00
Eric Paris
b625a4db24
Merge pull request #143 from sdomino/feature/hidden-commands
...
Feature/hidden commands
2015-09-08 18:19:22 -05:00
Eric Paris
edcf765d9f
Mangen: allow callers to specify header information
...
We previously had this weak argument called projectName which let you
set a single part of a man page header. Instead do the best we can if
the caller doesn't pass us anything, but let the caller specify anything
they want.
2015-09-08 18:52:09 -04:00
Eric Paris
cfecf1379c
manpage generation: Make sure parent in SEE ALSO has dashes
...
The CommandPath() for a parent might have a space (if .Parent() != .Root())
so we need to replace those spaces with `-`
2015-09-08 12:32:15 -04:00
Eric Paris
68f5a81a72
Merge pull request #141 from eparis/mac-completions
...
Enable bash completions on Macs
2015-09-04 09:11:03 -05:00
Eric Paris
32e87e3c8e
Enable bash completions on Macs
...
If they installed bash-completions from homebrew, this should make our
completions work.
2015-09-03 17:00:18 -04:00
Eric Paris
16b4170663
Merge pull request #138 from eparis/cleanup-helpfunc
...
Allow SetHelpFunc to overwrite the --help flag instead of just the help subcommand
2015-09-03 15:53:20 -05:00
Eric Paris
c2d19e9c43
Use the HelpFunc for the --help flag
...
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.
2015-09-01 14:25:38 -04:00
Eric Paris
27bf24802c
Redo HelpFunc() to work things other than the help subcommand
...
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...
2015-09-01 14:25:32 -04:00
Eric Paris
1f92281ffc
Merge pull request #135 from akutz/feature/custom-templ-funcs
...
Template Function Injection
2015-09-01 11:55:58 -05:00
Eric Paris
e15d674de6
Merge pull request #134 from apriendeau/master
...
#67 creates RunE functions to allow for errors to populate to the top
2015-09-01 11:51:29 -05:00
Eric Paris
99d2c51143
Merge pull request #137 from eparis/fix-help-template
...
Remove spurious } from the help template
2015-09-01 11:51:12 -05:00
Eric Paris
f7b419fbe1
Merge pull request #136 from eparis/late-init-help-flag-fix
...
Fix the late init help flag
2015-09-01 11:51:03 -05:00
Eric Paris
8f9b8c7cba
Remove spurious } from the help template
2015-09-01 12:03:37 -04:00
Eric Paris
ae28810f0e
Fix the late init help flag
2015-09-01 11:31:23 -04:00
Eric Paris
4c4f2d9417
Merge pull request #133 from eparis/late-init-help-flag
...
Initialize the --help flag as late as possible
2015-08-31 09:26:37 -05:00
Eric Paris
bab6d45bc6
Initialize the --help flag as late as possible
...
This should let users overwrite it with something custom. Like the help
sub-command.
2015-08-30 12:10:14 -04:00
Eric Paris
7cd6c9c000
Merge pull request #132 from AntonioMeireles/unbrand-man
...
turn generated man pages non k8s specific.
2015-08-28 12:09:21 -05:00
Eric Paris
e4993076d8
Merge pull request #128 from eparis/genManPages
...
Auto generation of a man pages
2015-08-21 01:11:45 -07:00
Eric Paris
9e7788657f
Auto generation of a man page
2015-08-21 01:10:13 -07:00
Eric Paris
db05184446
Merge pull request #127 from eparis/show-commandline-on-parent
...
Display pflag.CommandLine flags as if they were declared on the parent
2015-08-16 22:42:27 -07:00