Commit graph

785 commits

Author SHA1 Message Date
Alessio Treglia
40d34bca1b
Fix stderr printing functions (#894)
* Fix stderr printing functions

Follow-up of #822

* Errors go to stderr as per POSIX

* use PrintErrf() instead of extra call to Sprintf()

* Error messages should always be printed to os.Stderr.

* add test case for Print* redirection

Thanks: @bukowa for the patch.
2020-10-01 09:28:00 -06:00
John McBride
0bc8bfbe59
Remove secondary go mod to prevent broken go get (#1233) 2020-09-23 16:26:21 -06:00
Danny Hermes
7f8e83d936
Modifying "snake-case" to "kebab-case" for clarity. (#1196) 2020-09-16 09:27:58 -06:00
Arda Aytekin
8a39cb2614
Bug fix in README (#1199)
Bug fixed in `README.md`.
2020-09-16 09:26:27 -06:00
Fabrício José Souza
2a8d0f327d
Adding Kool to list of projects using cobra (#1224) 2020-09-15 08:45:35 -06:00
Umberto Baldi
6c06523c96
add arduino-cli to projects using cobra (#1117)
* add arduino-cli to projects using cobra
2020-09-15 08:44:32 -06:00
Luap99
8a63648dd9
Handle linebreaks in custom completions. (#1162)
If a command/flag description contains
a linebreak then the shell completion script
will interpret this as new command/flag.

To fix this we only use the first line
from the description in the output.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-09-09 11:27:42 -06:00
Luap99
50258f15eb
Complete subcommands when TraverseChildren is set (#1171)
* Complete subcommands when TraverseChildren is true in custom completion

The current custom completion logic does not complete
subcommands when a local flag is set. This is good unless
TraverseChildren is set to true where local flags
can be set on parent commands.

This commit allows subcommands to be completed
if TraverseChildren is set to true on the root cmd.

Closes #1170

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>

* Complete subcommands when TraverseChildren is true in bash completion

The current bash completion logic does not complete
subcommands when a local flag is set. There is also a bug
where subcommands are sometimes still getting completed. see: #1172

If TraverseChildren is true we should allow subcommands
to be completed even if a local flag is set.

Closes #1172

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-09-09 09:34:51 -06:00
Marc Lopez Rubio
02a0d2fbc9
doc: GenMarkdown skip Synopsis on empty long cmd (#1207)
This patch modifies the GenMarkdownCustom to skip writing a Synopsis
header with the `cmd.Short` duplicated both before and after the header.

Instead, it only writes the `### Synopsis` header and the paragraph when
a `cmd.Long` has some kind of content in it.

Adds `TestGenMdDocWithNoLongOrSynopsis` as the test case.

Signed-off-by: Marc Lopez <marc5.12@outlook.com>
2020-08-26 09:18:51 -06:00
Joshua Harshman
9ed1d713d6
bugfix/cli: Temporary fix for go get on cobra cli (#1200)
PR #1139 introduced a complexity that will have to be taken into account
as we figure out our release pipeline. This fix pins to cobrav1.0.0 as a
temporary workaround.

fixes: #1191
2020-08-23 13:45:41 -04:00
Michael Muré
8cfa4b4acf
Add documentation for Use (#1188) 2020-08-18 14:14:09 -06:00
Michael Muré
81e0311edd
modules: add a secondary go.mod to segregate CLI dependencies (#1139) 2020-08-15 10:44:17 -04:00
Michael Samoylov
5cdf8e26ba
Fix typo (#1187) 2020-08-11 08:39:51 -04:00
Felix Yan
a0b86e58f8
Correct a typo in doc/util.go (#1184) 2020-08-10 22:17:29 -06:00
Warren Fernandes
a738b60e52
Add CONTRIBUTING.md (#1183) 2020-08-10 22:14:21 -06:00
Erdal TAŞKESEN
96dc55577f
Update projects_using_cobra.md (#1147)
Adds git-bump, gh-labels, and random to list of projects
2020-08-05 09:36:41 -06:00
Warren Fernandes
0e27f22f6e
Add slack badge to point to cobra slack channel (#1181) 2020-07-31 09:53:44 -06:00
Marc Khouzam
c6fe2d4df8
Improve zsh completion documentation (#1169)
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
2020-07-19 16:02:46 -06:00
Dmitry Shurupov
19e41cf081
Adding werf to projects using cobra (#1163)
werf is a CI/CD & GitOps tool. Cobra is used in [werf's CLI](https://github.com/werf/werf/blob/master/cmd/werf/main.go).
2020-07-17 15:48:45 -06:00
Tam Mach
b95db644ed
Add golangci-lint in project using cobra (#1150) 2020-07-14 21:12:39 -06:00
umarcor
884edc58ad
update viper and pflag (#1012) 2020-07-13 11:55:00 -06:00
Marc Khouzam
675ae5f5a9
Fish does not accept - or : in vars (#1122)
Fixes #1121.
This is for programs that may contain a : or - in their name.

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
2020-07-10 14:12:46 -06:00
Diana Flach
5d5290759a
Update README.md (#1154)
I found this through a comment on an issue and thought this might save someone some time looking through the code.

fixes #1148
2020-07-10 14:06:59 -06:00
Sean Prince
207dc47664
Close #1152 by upgrading yaml.v2 to v2.3.0 (#1153) 2020-07-10 08:32:03 -04:00
Marc Khouzam
2c5a0d300f
Extend Go completions and revamp zsh comp (#1070) (#1070)
Replace the current Zsh completion with a Zsh completion solution based
on Go completions. This allows to support custom completions (based
on Go completions), but also to standardize the behavior of completion
across all shells.

Also, add support to Go completions for the bash completion annotations:
  BashCompFilenameExt (including Command.MarkFlagFilename() family)
                       - still supported by zsh
  BashCompSubdirsInDir - now supported by zsh
  BashCompOneRequiredFlag (including Command.MarkFlagRequired() family)
                       - now supported by zsh and fish

Finally, remove the suggestin of the = form of flag completion.
The = form is supported, but it will not be suggested to avoid having
duplicated suggestions.
2020-06-29 13:52:14 -06:00
Marc Khouzam
04318720db
Add completion for help command (#1136)
* Don't exclude 'help' from bash completions

Fixes #1000.

* Provide completion for the help command

1- Show 'help' as a possible completion
2- Provide completions for the help command itself

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Co-authored-by: Zaven Muradyan <voithos@google.com>
2020-06-16 14:49:26 -06:00
Alessandro (Ale) Segala
ed7b60e298
YAML documentation contains "Usage" (#1037) 2020-06-15 16:51:03 -06:00
Vaibhav Kaushik
1d3ac910d4
Update projects_using_cobra.md (#1113)
* Removing deprecated projects
* Update etcd website
2020-05-29 10:17:41 -06:00
Joshua Harshman
94a87a7b83
disable periodic labeler (#1112) 2020-05-08 09:53:33 -06:00
Marc Khouzam
5155946348
Ignore required flags when DisableFlagParsing (#1095)
When a command request to DisableFlagParsing, it should not fail due
to a missing required flag.  In fact, such a check will always fail
since flags weren't parsed!

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
2020-05-07 19:18:16 -06:00
Stefan Majer
aa5badda62
Metal Stack CLI is using cobra as well (#1094) 2020-05-07 19:13:20 -06:00
John Calabrese
a7aaa7cfac
replace labeler action with periodic-labeler (#1097)
* replace labeler action with periodic-labeler

this replaces the default labeler as it
does not label PRs from forks properly.

with periodic-labeler it should apply labels on
a cron to any PR and resolve the below bug:

https://github.com/spf13/cobra/issues/1092
2020-05-07 19:02:17 -06:00
Marc Khouzam
f8fdd17383
Complete command names even if ValidArgs present (#1088)
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
2020-05-07 15:04:14 -06:00
John McBride
e392f3204d
Man pages won't have auto gen tag when option is disabled (#1104)
* Man pages wont have  auto gen tag when option is disabled

- this addresses #741

* Add documentation for doc generation and a changelog
2020-04-29 11:15:55 -06:00
Warren Fernandes
41fd44e1df
Fix cobra init cmd help documentation (#1108)
Adds tests for other cases where we do not expect projects to be created
for absolute paths and relative paths in GOPATH.
2020-04-28 16:59:18 -06:00
Warren Fernandes
44d55fb4d3
Fix cobra command README (#1106)
Describes the behavior of custom LICENSE generation using properties in
~/.cobra.yml
2020-04-28 11:49:46 -06:00
Marc Khouzam
11ba63fc3b
Add Helm as project using Cobra (#1103)
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
2020-04-25 09:03:04 -06:00
Warren Fernandes
090d94f474
Move projects using Cobra (#1090)
Since there are so many projects using Cobra, we created a separate
document to list them
2020-04-16 11:00:24 -06:00
Amit Botzer
8c638d3f90
Fixed typo. (#1087)
Changed 'applicaton' to 'application'.
2020-04-10 15:30:10 -06:00
Marc Khouzam
a684a6d7f5
Fish completion using Go completion (#1048)
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
2020-04-10 13:56:28 -06:00
John McBride
7fead4bf3b
Remove/replace SetOutput on Command - deprecated (#1078)
Replace SetOutput on Command - deprecated
2020-04-06 11:36:04 -06:00
Julien
47414285f9
Add Github CLI to list of projects using Cobra (#1034) 2020-04-06 11:30:17 -06:00
Marc Khouzam
b84ef40338
Rename BashCompDirectives to ShellCompDirectives (#1082)
Since the completion directives will be used for all shells, and that
these names will be consumed by users, this is a more appropriate name.

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
2020-04-06 11:28:44 -06:00
Marc Khouzam
b80aeb17fc
Add support for custom completions in Go (#1035)
This commit allows programs using Cobra to code their custom completions
in Go instead of Bash.

The new ValidArgsFunction field is added for commands, similarly to
ValidArgs.  For flags, the new function
Command.RegisterFlagCompletionFunc() is added.

When either of the above functions is used, the bash completion script
will call the new hidden command '__complete', passing it all
command-line arguments. The '__complete' command will call
the function specified by Command.ValidArgsFunction or by
Command.RegisterFlagCompletionFunc to obtain completions from the
program itself.

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
2020-04-03 13:43:43 -06:00
John Calabrese
138b98f39d
add support for autolabel stale PR (#1075)
* add support for autolabel stale PR

automatically labels stale PRs

* stale label is kind/stale

updates the stale label to reflect
existing project labels

* adds a relevant stale message

for both PRs and issues there is now a more
descriptive and relevant message
when the action marks something stale

* no auto-close on stale issues/prs

uses the exempt flag to ignore issues already marked
stale. this will allow us to auto label stale,
and then ignore them so they do not get auto
closed.
2020-04-02 10:55:31 -06:00
John Calabrese
d88d9a09e9
Add Labeler Actions (#1074)
* adds labels to PRs

this will label PRs such that 
the maintainers have visibility into 
the breadth of the changes being suggested

* Create labeler.yml

* add all shell completions to labeler

any changes to and autocomplete for any shell
will now be auto labelled as impacting the autocompletion functionality
2020-04-02 09:26:08 -06:00
Joshua Harshman
bbffa3aa94
rm circle ci badge (#1073) 2020-04-01 10:27:47 -06:00
Kanji Yomoda
f62883520e
Replace deprecated SetOutput func with SetOut and SetErr in test (#1053) 2020-04-01 10:25:22 -06:00
Joshua Harshman
6607e6b860
Partial Revert of #922 (#1068)
Issue Reference: https://github.com/spf13/cobra/issues/1056

https://github.com/spf13/cobra/pull/922 introduced a new error
type that emitted when a command was not runnable. This caused
all commands w/o a run function set to error w/ that message and a status code of 1.

This change reverts the addition of that new error. Similar
functionality can be accomplished by leveraging RunE.
2020-03-27 14:38:32 -06:00
Dave Henderson
95f2f73ed9
Add short version flag -v when not otherwise set (#996)
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
2020-02-28 11:13:40 -07:00