Commit Graph

940 Commits

Author SHA1 Message Date
Paul Meyer
2a7647ff46
Clarify SetContext documentation (#1748) 2022-08-29 22:12:56 -04:00
Unai Martinez-Corral
7045405250
ci: test on Golang 1.19 (#1782)
* ci: test on Golang 1.19

* ci: run golangci-lint on golang 1.19

* Adds `check-latest` for setup-go action v3

* ci/golangci-lint: use latest version available in setup-go's manifest

Signed-off-by: John McBride <jpmmcbride@gmail.com>
Signed-off-by: umarcor <unai.martinezcorral@ehu.eus>
Co-authored-by: John McBride <jpmmcbride@gmail.com>
2022-08-29 21:35:16 -04:00
Brian Pursley
22b617914c
fix: show flags that shadow parent persistent flag in child help (#1776)
This fixes a bug where a child flag that shadows (has the same
name as) a parent persistent flag would not be shown in the
child command's help output and the parent flag would be shown
instead under the global flags section.

This change makes the help output consistent with the
observed behavior during execution, where the child flag is
the one that is actually used.
2022-08-28 12:46:39 -04:00
Tobias Klauser
dbf85f6104
Update gopkg.in/yaml.v2 to gopkg.in/yaml.v3 (#1766)
API v3 was released in 2019 [1]. Update from the v2 API, no changes to
the packages's use needed and no breaking changes expected.

[1] https://ubuntu.com/blog/api-v3-of-the-yaml-package-for-go-is-available
2022-08-13 16:18:46 -06:00
Ville Skyttä
f911c0b89c
fix(bash-v2): activeHelp length check syntax (#1762)
```shell
$ set -u
$ foo=()
$ echo ${#foo}
bash: foo: unbound variable
echo ${#foo[*]}
0
```
The above shows that an empty array needs the suffix `[*]` when checking its length, or else it is considered unbound.
2022-08-13 17:44:47 -04:00
Zoran Regvart
7790bf97fd
fix: correct command path in see_also for YAML doc (#1771)
The `see_also` section for child commands would include only the name of
the commands. This adds the whole path, similar to how it's done for the
other documentation formats.
2022-08-13 17:31:45 -04:00
dependabot[bot]
6bf8cd8582
build(deps): bump github.com/inconshreveable/mousetrap (#1774) 2022-08-13 21:02:01 +00:00
Florian Forster
965924ac89
docs: add zitadel to the list (#1772) 2022-08-04 11:18:09 -04:00
Javier López Barba
162534f92f
doc: Add Okteto for projects using Cobra (#1759)
Signed-off-by: Javier López Barba <javier@okteto.com>
2022-07-20 16:45:07 +03:00
Ikko Ashimine
a0aadc68eb
Spelling for GitHub CLI (#1744) 2022-07-07 07:54:19 +03:00
Tobias Klauser
69083f81b2
Add Cilium to projects using Cobra (#1745) 2022-06-28 15:19:33 -06:00
Yevgeny Pats
bba9331d4e
doc: Add CloudQuery for projects using Cobra (#1742) 2022-06-25 19:17:06 +03:00
Miguel Duarte Barroso
3d38d18a23
Add KubeVirt as a project using cobra (#1741)
Reaching out on behalf of KubeVirt, an add-on for Kubernetes, enabling
users to run Virtual Machines on Kubernetes pods.

Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2022-06-23 09:36:12 -06:00
dependabot[bot]
06b06a9dc9
Bump golangci/golangci-lint-action from 3.1.0 to 3.2.0 (#1697)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.1.0...v3.2.0)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-20 20:06:17 -06:00
Marc Khouzam
5f2ec3c897
Update shell completion to respect flag groups (#1659)
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Co-authored-by: Marc Khouzam <marc.khouzam@montreal.ca>
2022-06-20 20:04:28 -06:00
Paul Holzinger
b9ca5949e2
use errors.Is() to check for errors (#1730)
Since go 1.13 you can wrap errors. This make it no longer possible to
compare with `==`, instead you have to compare with `errors.Is()`.

I noticed this problem because -h was no longer working after I stared
wrapping the errors in my custom FlagErrorFunc function.
Note that this is only a problem when a custom help flag is defined.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-06-20 20:02:33 -06:00
Unai Martinez-Corral
ea94a3db55
undefined or nil Args default to ArbitraryArgs (#1612) 2022-06-20 20:00:50 -06:00
Marc Khouzam
7c9831d376
Fix handling of descriptions for bash v3 (#1735)
Fixes #1734

Tab characters that introduce completion descriptions weren't properly
being handled with bash v3.  This change fixes that.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2022-06-20 00:11:21 -04:00
kida
ed7bb9dda4
Add unit test for fish completion (#1515) 2022-06-19 22:38:49 -04:00
Marc Khouzam
f464d6c82e
Add Active Help support (#1482) 2022-06-15 20:08:16 -04:00
dependabot[bot]
7dc8b004e6
Bump actions/setup-go from 2 to 3 (#1660)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2 to 3.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-15 16:08:55 -06:00
xuwu
87ea1807f7
Modify brew prefix path in macOS system (#1719) 2022-06-12 22:22:49 -04:00
Ian Wahbe
ca8e3c2779
Add Pulumi as a project using cobra (#1720)
* Add Pulumi as a project using cobra
2022-06-08 17:12:54 -04:00
Tom Payne
37d481d4d4
fix: Don't complete _command on zsh (#1690)
Previously the generated zsh completion script started with the line

    #compdef _<command> <command>

where <command> is the command that the zsh completion script is
generated for.

This enabled completions for both <command> and _<command>, but
_<command> is the completion function itself and should not be
completed. Furthermore, attempting to autocomplete _<command> (e.g.
typing "_<command><Space><Tab>" in a zsh shell) causes zsh to hang.

This commit fixes the #compdef line to only complete <command>, not
_<command>.

Co-authored-by: Arvid Norlander <VorpalBlade@users.noreply.github.com>
2022-06-05 15:45:59 -04:00
Ville Skyttä
5b11656e45
perf(bash-v2): read directly to COMPREPLY on descriptionless short circuit (#1700)
Not that it'd really matter that much performancewise given the level we
are at for this case, but this change makes the short circuit roughly
twice as fast on my box as it was for the 1000 rounds done in
marckhouzam/cobra-completion-testing.

Perhaps more importantly, this makes the code arguably slightly cleaner.
2022-05-17 20:57:08 -04:00
Andreas Deininger
ffa8860dbe
Change links from http:// to https:// (#1695) 2022-05-17 14:28:13 -04:00
Ville Skyttä
e1ded5cd94
fix(bash-v2): skip empty completions when filtering descriptions (#1691)
`read` gives a last null value following a trailing newline.

Regression from fb8031162c.
2022-05-17 13:47:47 -04:00
dependabot[bot]
8afe9d1b56
Bump github.com/cpuguy83/go-md2man/v2 from 2.0.1 to 2.0.2 (#1688)
Bumps [github.com/cpuguy83/go-md2man/v2](https://github.com/cpuguy83/go-md2man) from 2.0.1 to 2.0.2.
- [Release notes](https://github.com/cpuguy83/go-md2man/releases)
- [Commits](https://github.com/cpuguy83/go-md2man/compare/v2.0.1...v2.0.2)

---
updated-dependencies:
- dependency-name: github.com/cpuguy83/go-md2man/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-14 17:16:07 -06:00
Hugo
25f5bb5f97
Prefer ReplaceAll instead of Replace(..., -1) (#1530) 2022-05-14 14:10:36 -06:00
Ville Skyttä
9e88759b19
perf(bash-v2): speed up filtering menu-complete descriptions (#1692)
Similarly as fb8031162c (+ the empty entry
fix) did for the "regular", non-menu completion cases.
2022-05-04 16:23:02 -04:00
Ville Skyttä
fb8031162c
perf(bash-v2): speed up filtering entries with descriptions (#1689)
Use simple prefix match instead of single word `compgen -W` command
substitution for each candidate match.
2022-05-03 21:34:55 -04:00
Ville Skyttä
95d7df1858
perf(bash-v2): short-circuit descriptionless candidate lists (#1686)
If the list of candidates has no descriptions, short circuit all the
description processing logic, basically just do a `compgen -W` for the
whole list and be done with it.

We could conceivably do some optimizations like this and more when
generating the completions with `--no-descriptions` in Go code, by
omitting some parts we know won't be needed, or doing some things
differently. But doing it this way in bash, the improvements are
available also to completions generated with descriptions enabled when
they are invoked for completion cases that produce no
descriptions. The result after this for descriptionless entries seems
fast enough so it seems there's no immediate need to look into doing
that.
2022-05-03 21:16:07 -04:00
Ville Skyttä
f17e5a27c9
style(bash): out is not an array variable, do not refer to it as such (#1684)
For legacy bash completions, similarly as commit
4f0facbcee is for bash completions v2.

As a side effect, fixes test suite with shellcheck 0.8.0 installed;
apparently the 0.7.0 that's in GitHub Actions' ubuntu-latest at the
moment does not flag the array quoting related issue that was provoked
from 0.8.0 before this change.
2022-05-02 21:41:07 -04:00
Ville Skyttä
09d6ba690f
perf(bash-v2): standard completion optimizations (#1683)
Refactor to remove two loops over the entire list of candidates.

Format descriptions only for completions that are actually going to be
displayed, instead of for all candidates.

Format descriptions inline in completions array, removing need for a
command substitution/subshell and a printf escape per displayed
completion.
2022-05-02 21:00:51 -04:00
Ville Skyttä
4f0facbcee
style(bash-v2): out is not an array variable, do not refer to it as such (#1681)
Even though this to my surprise works, it doesn't accomplish anything
but some confusion. Remove it.
2022-04-27 22:27:52 -04:00
Ville Skyttä
2722a75ba3
perf(bash-v2): use backslash escape string expansion for tab (#1682)
Using a command substitution, i.e. a subshell, with `printf` is
expensive for this purpose. For example `__*_format_comp_descriptions`
is run once for each completion candidate; the expense adds up and
shows when there are a lot of them.
2022-04-27 22:02:30 -04:00
Daniel Nguyen
d8184d3269
Fix typo sh completion docs (#1678) 2022-04-26 20:39:55 -04:00
dependabot[bot]
b9460ccc12
Bump codelytv/pr-size-labeler from 1.8.0 to 1.8.1 (#1661)
Bumps [codelytv/pr-size-labeler](https://github.com/codelytv/pr-size-labeler) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/codelytv/pr-size-labeler/releases)
- [Commits](https://github.com/codelytv/pr-size-labeler/compare/v1.8.0...v1.8.1)

---
updated-dependencies:
- dependency-name: codelytv/pr-size-labeler
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-21 08:20:16 -04:00
Miloš Živković
89d7b832c7
Add Polygon Edge as a project using Cobra (#1672) 2022-04-20 10:23:27 -04:00
John Schnake
68b6b24f0c
Add ability to mark flags as required or exclusive as a group (#1654)
This change adds two features for dealing with flags:
 - requiring flags be provided as a group (or not at all)
 - requiring flags be mutually exclusive of each other

By utilizing the flag annotations we can mark which flag groups
a flag is a part of and during the parsing process we track which
ones we have seen or not.

A flag may be a part of multiple groups. The list of flags and the
type of group (required together or exclusive) make it a unique group.

Signed-off-by: John Schnake <jschnake@vmware.com>
2022-04-17 16:04:57 -05:00
Paul Chesnais
bf6cb5804d
Wrap printf tab with quotes (#1665)
Without this, slightly older versions of zsh fail to correctly parse the output of the __complete
command. Tested that with zsh 5.0.2 and zsh 5.8. Since this is just correctly quoting the output of
a command, it shouldn't cause any compatibility issues.
2022-04-14 00:30:27 -04:00
John McBride
9d15fe657a
Update stale-bot (#1609)
- Only label issues after feb 01, 2022
- Apply lifecycle/stale after 60 days
- Close issue and apply lifecycle/rotten after another 30 days

Signed-off-by: John McBride <jmcbride@vmware.com>
2022-04-08 11:46:22 -06:00
Unai Martinez-Corral
5271cf4342
ci/test: RICHGO_FORCE_COLOR (#1647) 2022-03-29 20:05:24 -04:00
John McBride
ab42c937ec
Adds size labeler GitHub action (#1610)
Signed-off-by: John McBride <jmcbride@vmware.com>
2022-03-29 16:56:24 -06:00
dependabot[bot]
52e6099aea
Bump actions/checkout from 2 to 3 (#1619)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-26 09:50:12 -06:00
dependabot[bot]
5414d3d45d
Bump golangci/golangci-lint-action from 2 to 3.1.0 (#1615)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 2 to 3.1.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v2...v3.1.0)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-25 09:46:21 -06:00
dependabot[bot]
cf0df73277
Bump actions/labeler from 3 to 4 (#1620)
Bumps [actions/labeler](https://github.com/actions/labeler) from 3 to 4.
- [Release notes](https://github.com/actions/labeler/releases)
- [Commits](https://github.com/actions/labeler/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/labeler
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-25 09:45:15 -06:00
dependabot[bot]
3723151d17
Bump actions/cache from 2 to 3 (#1640)
Bumps [actions/cache](https://github.com/actions/cache) from 2 to 3.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-25 09:44:51 -06:00
dependabot[bot]
1568491a09
Bump actions/stale from 1 to 5 (#1618)
Bumps [actions/stale](https://github.com/actions/stale) from 1 to 5.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v1...v5)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-25 09:44:32 -06:00
Neville Bokdawalla
d622355c84
Changed branch name in the cobra generator link to 'main' (#1645) 2022-03-24 19:20:54 -04:00