Commit Graph

965 Commits

Author SHA1 Message Date
Paul Holzinger 7223a997c8
powershell completion fix no file comp directive (#1363)
Make sure to filter the returned completions before we check if
there are valid completions left.

Fixes #1362

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-05-03 10:25:30 -06:00
Marc Khouzam 06e4b59b20
Allow fish comp to support trailing empty lines (#1284)
Some programs may output extra empty lines after the directive.
Those lines must be ignored for fish shell completion to work.
zsh and bash are not impacted.

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>

Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>
2021-05-03 10:23:34 -06:00
Unai Martinez-Corral 3ed6a394b6
ci/MSYS2: go install @latest (#1366) 2021-05-03 10:08:39 -06:00
Ville Skyttä eb3b6397b1
Bash completion variable leak fixes (#1352)
Fixes bash variables leaking into the parent shell without `local`
2021-02-18 08:26:03 -07:00
John McBride b55fa79836
Add PR labeler with pull_request_target (#1338)
* Add PR labeler with pull_request_target
2021-02-15 10:48:09 -07:00
Marc Khouzam b312f0a8ef
Create 'completion' command automatically (#1192)
Make it easier for programs to provide shell completion by creating
the 'completion' command automatically.

If a 'completion' command is already provided by the program, Cobra
will use that one instead.

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
2021-02-15 10:47:01 -07:00
Paul Holzinger ded486a867
Fix trailing whitespace in the powershell completion script (#1342)
Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-14 10:27:21 -07:00
Anthony Fok 893ebf6e36
Fix typo 2021-02-10 12:40:59 -07:00
Anthony Fok be1efc850f
Update CHANGELOG.md for v1.1.3 2021-02-10 12:35:57 -07:00
Anthony Fok 7f95502478
Update CHANGELOG.md for v1.1.2 2021-02-09 18:39:00 -07:00
Anthony Fok 07445ea179
Copyedit shell-completion related documentation 2021-02-09 14:08:42 -07:00
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