Commit graph

954 commits

Author SHA1 Message Date
Unai Martinez-Corral
b73b344b63
ci: add GitHub Actions workflow 'Test' (#1339)
Adds a "test" action which will run side by side (for now) with Travis

Co-authored-by: John McBride <jpmmcbride@gmail.com>
2021-02-09 08:48:59 -07:00
Unai Martinez-Corral
652c755d37
Use golangci-lint (#1044)
Use golangci-lint. Repair warnings and errors resulting from linting.
2021-02-07 17:08:50 -07:00
Joshua Harshman
1d71ff0270
Deprecate Go < 1.14 (#1323)
In accordance with our adopted best practices, the main branch and the
next major release of Cobra will deprecate older and un-maintained
versions of Golang.

fix #1322
2021-02-01 15:59:47 -07:00
Anthony Fok
1135bdeceb
Update gopkg.in/yaml.v2 to v2.4.0
The previous breaking change in yaml.v2 v2.3.0 has been reverted,
see https://github.com/go-yaml/yaml/pull/670
2021-02-01 12:44:33 -07:00
Joshua Harshman
9df156e6d1
Cobra User Contract (#1292)
* Add some guiding principals to the project.

Establish an understanding between user and maintainer.
Set a goal for releases, security fixes and bug patches.

* fix grammatical errors
2021-01-26 10:55:24 -07:00
John McBride
ff416ad438
Revert "Add the ability to specify a filePostpender in GenMarkdownTreeCustom (#1270)" (#1317)
This reverts commit 23a6174c7f.
2021-01-23 16:05:55 -07:00
Joon-Ho Son
23a6174c7f
Add the ability to specify a filePostpender in GenMarkdownTreeCustom (#1270) 2021-01-20 20:33:16 -07:00
Maxime Bury
4384b91fb4
Bump license year to 2021 in golden files (#1309)
* Update main.go.golden

* Update root.go.golden

* Update test.go.golden
2021-01-16 20:41:43 -05:00
Paul Holzinger
a4ab3fa09e
powershell completion with custom comp (#1208)
The current powershell completion is not very capable.

Let's port it to the go custom completion logic to have a
unified experience accross all shells.

Powershell supports three different completion modes

- TabCompleteNext (default windows style - on each key press the next option is displayed)
- Complete (works like bash)
- MenuComplete (works like zsh)

You set the mode with `Set-PSReadLineKeyHandler -Key Tab -Function <mode>`

To keep it backwards compatible `GenPowerShellCompletion` will not display descriptions.
Use `GenPowerShellCompletionWithDesc` instead. Descriptions will only be displayed with
`MenuComplete` or `Complete`.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-12-29 07:57:32 -07:00
Jon Love
471c9ac367
Add the new Twitch CLI to to projects_using_cobra.md (#1301) 2020-12-29 07:39:22 -07:00
namusyaka
7df62f7668
fix typos (#1274) 2020-12-04 12:34:11 -07:00
zaataylor
39b5a91b20
README.md Readability Improvements (#1228)
I made some small changes to the README.md file to enhance its readability.
2020-12-04 12:15:09 -07:00
Vincent
08c51e585c
Add ORY Hydra & Kratos to projects_using_cobra.md (#1273)
* Add ORY Hydra & Kratos to projects_using_cobra.md

* fix: alphabetical order

my bad!

* fix: ORY to Ory

I think now it should be good, 
sorry for the confusion!
2020-11-09 16:46:15 -07:00
Sascha Steinbiss
86f8bfd7fe
fix manpage building with new go-md2man (#1255)
This addresses #1049 by changing the format of the generated
Markdown input.
2020-10-18 12:59:26 -06:00
Marc Khouzam
f32f4ef15b
Don't use yaml.v2 2.3.0 which has a breaking change (#1259)
yaml.v2 contains a breaking change from
https://github.com/go-yaml/yaml/pull/571

yaml.v2 2.2.8 does not have that change and also addresses the CVE that
was behind the move to yaml.v2 2.3.0.  This commit reverts to using
yaml.v2 2.2.8

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
2020-10-18 12:50:48 -06:00
Adam Demuri
142dfb15a8
Add example for making persistent flags required (#1135) 2020-10-14 09:53:09 -06:00
Alessio Treglia
723d0c36fc
Add tendermint and cosmos-sdk to the list of projects using cobra (#855)
* Add tendermint and cosmos-sdk to the list of projects using cobra

Co-authored-by: Steve Francia <steve.francia@gmail.com>
2020-10-14 09:51:35 -06:00
Matej Vasek
b97b5ead31
fix: fish output redirection (#1247)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2020-10-05 21:54:06 -06:00
midchildan
f64bfa1e08
Fix zsh completion not working on the first time in a shell session (#1237)
The zsh completion script output by cobra is a stub completion function
which replaces itself with the actual completion function. This
technique enables cobra to define helper functions without splitting the
completion script into multiple files.  However, the current
implementation forgets to call the actual completion function at the end
of the stub function, meaning that completion won't work the first time
it's invoked in a shell session. This commit is a fix for this problem.
2020-10-03 19:25:07 -06:00
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