Commit graph

1027 commits

Author SHA1 Message Date
Mavaddat Javid
955cac7eb9
ignore resolve errors 2023-10-30 11:48:03 -04:00
Mavaddat Javid
94243fef09
need description property 2023-10-30 11:44:11 -04:00
Mavaddat Javid
8b4835d0a9
Merge branch 'spf13:main' into patch-1 2023-10-30 11:03:27 -04:00
dependabot[bot]
48cea5c87b
build(deps): bump actions/checkout from 3 to 4 (#2028) 2023-10-30 10:21:48 +00:00
Mavaddat Javid
c901861b50
Update powershell_completions.go
Typo in previous. Change `$_` PSItem to `$__%[2]sCmd`
2023-10-29 18:47:11 -04:00
Mavaddat Javid
caeed9f2a4
Update powershell_completions.go
Incorporate @bartoncasey insight about typical alias usage in https://github.com/spf13/cobra/pull/2049
2023-10-29 17:00:24 -04:00
Ville Skyttä
22953d8845
Replace all non-alphanumerics in active help env var program prefix (#1940)
* Replace all non-alphanumerics in active help env var program prefix

There are other characters besides the dash that are fine in program
names, but are problematic in environment variable names. These include
(but are not limited to) period, space, and non-ASCII letters.

* Another change in docs to mention non-ASCII-alphanumeric instead of just dash
2023-10-29 12:06:51 -06:00
Marc Khouzam
00b68a1c26
Add tests for flag completion registration (#2053)
Different problems have been reported about flag completion registration.
These two tests are the cases that were not being verified but had been
mentioned as problematic.

Ref:
- https://github.com/spf13/cobra/issues/1320
- https://github.com/spf13/cobra/pull/1438#issuecomment-872928669

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2023-10-28 16:11:59 -04:00
Marc Khouzam
b711e8760b
Don't complete --help flag when flag parsing disabled (#2061)
Fixes #2060

When a command sets `DisableFlagParsing = true` it requests the
responsibility of doing all the flag parsing. Therefore even the
`--help/-f/--version/-v` flags should not be automatically completed
by Cobra in such a case.

Without this change the `--help/-h/--version/-v` flags can end up being
completed twice for plugins: one time from cobra and one time from the
plugin (which has set `DisableFlagParsing = true`).

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2023-10-28 16:10:06 -04:00
Marc Khouzam
8b1eba4761
Fix linter errors (#2052)
When using golangci-lint v1.55.0 some new errors were being reported.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2023-10-27 06:23:45 -04:00
vkhoroz
4cafa37bc4
Allow running persistent run hooks of all parents (#2044)
Currently, only one of the persistent pre-runs and post-runs is executed.
It is always the first one found in the parents chain, starting at this command.
Expected behavior is to execute all parents' persistent pre-runs and post-runs.

Dependent projects implemented various workarounds for this:
- manually building persistent hook chains (in every hook).
- applying some kind of monkey-patching on top of Cobra.

This change eliminates the necessity for such workarounds
by allowing to set a global variable EnableTraverseRunHooks.

Tickets:
- https://github.com/spf13/cobra/issues/216
- https://github.com/spf13/cobra/issues/252

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
2023-10-21 20:36:12 -04:00
dependabot[bot]
5c962a221e
build(deps): bump github.com/cpuguy83/go-md2man/v2 from 2.0.2 to 2.0.3 (#2047) 2023-10-16 10:50:33 +00:00
dependabot[bot]
efe8fa3e44
build(deps): bump actions/setup-go from 3 to 4 (#1934) 2023-10-15 11:16:50 +00:00
Haoming Meng
95d8a1e45d
Add notes to doc on preRun and postRun condition (#2041) 2023-10-09 08:50:40 -04:00
Alexandru-Claudius Virtopeanu
bd4d1655f6
feat: add getters for flag completions (#1943) 2023-09-25 20:04:25 -04:00
Souma
0c72800b8d
Customizable error message prefix (#2023) 2023-09-08 13:29:06 -04:00
Nuno Adrego
c5dacb3ea4
ci: test golang 1.21 (#2024) 2023-09-07 20:30:51 -04:00
Unai Martinez-Corral
285460dca6
command: temporarily disable G602 due to securego/gosec#1005 (#2022) 2023-08-29 10:04:59 -04:00
dependabot[bot]
4955da7c11
build(deps): bump golangci/golangci-lint-action from 3.6.0 to 3.7.0 (#2021) 2023-08-28 18:53:34 +00:00
Jun Nishimura
fd865a44e3
minor corrections to unit tests (#2003) 2023-07-23 07:31:55 -04:00
gocurr
60d056d157
doc: fix typo, Deperecated -> Deprecated (#2000) 2023-07-20 11:27:44 -04:00
Unai Martinez-Corral
66b215ba18
golangci: enable 'unused' and disable deprecated replaced by it (#1983) 2023-07-18 09:51:36 -04:00
Martijn Evers
c81c46a015
Add 'one required flag' group (#1952) 2023-07-16 12:38:22 -04:00
Unai Martinez-Corral
dcb405a939
Move documentation sources to site/content (#1428) 2023-06-20 17:15:36 -04:00
dependabot[bot]
cbe4865373
build(deps): bump golangci/golangci-lint-action from 3.5.0 to 3.6.0 (#1976) 2023-06-20 20:46:35 +00:00
Mavaddat Javid
f43b653d17
Update powershell_completions.go
Preliminary assignment before use
2023-06-19 16:56:55 -04:00
Mavaddat Javid
d17f539906
Merge branch 'main' into patch-1 2023-06-19 16:46:04 -04:00
Mavaddat Javid
0676e2612e
Update powershell_completions.go
Implement curly bracket technique like https://github.com/spf13/cobra/pull/1960
2023-06-19 16:44:38 -04:00
Paul Holzinger
fdee73b4a0
powershell: escape variable with curly brackets (#1960)
This fixes an issue with program names that include a dot, in our case
`podman.exe`. This was caused by the change in commit 6ba7ebbc.

Fixes #1853

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-06-19 12:16:18 -04:00
Branch Vincent
988bd76139
test: make fish_completions_test more robust (#1980)
Use temporary files instead of assuming the current directory is
writable. Also, if creating a temporary file still returns an error,
prevent the test from failing silently by replacing `log.Fatal` with
`t.Fatal`.
2023-06-16 10:25:30 -04:00
Mavaddat Javid
cc6f7e0edd
Forgot about the original alias!
In my exuberance to include all the other aliases, I accidentally removed the original alias that was previously the only one being registered for autocompletion. I have restored this `'%[1]s'`.
2023-06-14 11:58:34 -04:00
Taavi Väänänen
2246fa82e9
Fix grammar: 'allows to' (#1978)
The use in generated bash completion files is getting flagged by
Lintian (the Debian package linting tool).

Signed-off-by: Taavi Väänänen <hi@taavi.wtf>
2023-06-13 11:12:49 -04:00
Mavaddat Javid
a6a563d656
completers ∀x∈ {cmds, aliases} in powershell_completions.go
pwsh completers ∀x∈ {cmds, aliases}
2023-06-12 10:46:19 -04:00
dependabot[bot]
0e3a0bfe91
build(deps): bump golangci/golangci-lint-action from 3.4.0 to 3.5.0 (#1971) 2023-06-12 02:39:30 +00:00
Tom Payne
284f410104
Fix typo in fish completions (#1945) 2023-04-08 00:47:33 -04:00
Marc Khouzam
4dd4b25de3
Update main image to better handle dark background (#1883)
Fixes #1880

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
Co-authored-by: Deleplace <deleplace2015@gmail.com>
2023-03-22 18:41:51 -04:00
Marc Khouzam
45360a55cc
Allow sourcing zsh completion script (#1917)
Although it is not the recommended approach, sourcing a completion
script is the simplest way to get people to try using shell completion.
Not allowing it for zsh has turned out to complicate shell completion
adoption.  Further, many tools modify the zsh script to allow sourcing.

This commit allows sourcing of the zsh completion script.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2023-03-22 18:41:05 -04:00
Luiz Carvalho
c8a20a16ba
Document suggested layout for subcommands (#1930)
Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
2023-03-16 21:03:29 -04:00
Florent Poinsard
b197a24504
Update projects_using_cobra.md (#1932)
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
2023-03-14 08:28:50 -04:00
Unai Martinez-Corral
9e6b58afc7
update copyright year (#1927) 2023-03-05 21:28:31 -05:00
Unai Martinez-Corral
fb3652402b
ci: test Golang 1.20 (#1925) 2023-03-05 21:11:33 -05:00
Unai Martinez-Corral
c7300f0bdd
ci: deprecate go 1.16 (#1926) 2023-03-05 21:07:19 -05:00
Oldřich Jedlička
567ea8ebc9
Add support for PowerShell 7.2+ (#1916)
PowerShell 7.2 has changed the way arguments are passed to executables.
This was originally an experimental feature in 7.2, but as of 7.3 it is
built-in. A simple "" is now sufficient for passing empty arguments, no
back-tick escaping is required.

Fixes #1849

Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com>
Co-authored-by: Oldřich Jedlička <oldrich.jedlicka@rohlik.cz>
2023-02-25 16:30:37 -05:00
Gyanendra Mishra
3daa4b9c36
Add keeporder to shell completion (#1903)
This allows programs to request the shell to maintain the order of completions that was returned by the program
2023-02-25 15:57:12 -05:00
John McBride
a516d4132c
Removes stale bot from GitHub action (#1908)
Signed-off-by: John McBride <jpmmcbride@gmail.com>
2023-02-13 20:49:03 -07:00
dependabot[bot]
e839bb342f
build(deps): bump golangci/golangci-lint-action from 3.3.1 to 3.4.0 (#1902) 2023-02-12 01:27:13 +00:00
Ggg6542
87ebcd8f98
Update shell_completions.md (#1907)
align documentation with the code : completions.go:452
2023-02-08 21:11:53 -05:00
janhn
8b8ee8754c
Improve MarkFlagsMutuallyExclusive example in User Guide (#1904) 2023-02-06 06:15:40 -05:00
Shihta Kuan
d022c0fe2b
Add documentation about disabling completion descriptions (#1901) 2023-01-30 12:58:20 -05:00
dependabot[bot]
4fa4fdf5cd
build(deps): bump github.com/inconshreveable/mousetrap (#1872) 2023-01-03 02:43:06 +00:00