Commit graph

981 commits

Author SHA1 Message Date
Jack Wright
303dd2517f "Reverted to old version without formatting changes and readded nushell" 2022-12-23 20:40:17 -08:00
Jack Wright
cb60acd3ab "Added nushell to list of shell autompletes" 2022-12-23 20:39:54 -08:00
Jack Wright
107986cb5e
Update completions.go
Co-authored-by: Marc Khouzam <marc.khouzam@gmail.com>
2022-12-23 20:31:48 -08:00
Jack Wright
49d58810e6
Update completions.go
Co-authored-by: Marc Khouzam <marc.khouzam@gmail.com>
2022-12-23 20:31:38 -08:00
Jack Wright
6e3abc68be
Update completions.go
Co-authored-by: Marc Khouzam <marc.khouzam@gmail.com>
2022-12-23 20:31:30 -08:00
Jack Wright
cfee99c892 "removing extra lines/whitespace" 2022-12-23 20:30:18 -08:00
Jack Wright
b3a1d72b8b "fixing completions that contain a /" 2022-12-16 09:50:05 -08:00
Jack Wright
fe8bf5e1bd "ignoring return value when directive is ShellComp#directiveFilterFileExt" 2022-12-16 09:32:22 -08:00
Jack Wright
f366bb2799 "fixing oddities with fuzzy searching and bug with active help" 2022-12-15 13:23:38 -08:00
Jack Wright
4ad4930a12 Incorporating pull request feedback
- Fixing completion on full paths
- Fixing completion with equals in flags
- Fixing fuzzy search
- Typos
2022-11-28 13:39:12 -08:00
Jack Wright
95f2d8e38a Added a whitelist to add cobra apps to to prevent non-cobra apps from
being excuted
2022-11-27 15:06:59 -08:00
Jack Wright
1c908e13f5 Added nushell to the Use: line 2022-11-27 13:55:50 -08:00
Jack Wright
0e4db1bd14 Incorporating pull request feedback.
- Renamed completer to be cobra_completer to match docs
- Added whitespace after each completion
- Implemented ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp
- Disabled active help as it isn't supported by nushell
- Added nushell to the default completion command
2022-11-27 13:46:13 -08:00
Jack Wright
e687d2e9e1 Changed the nushell completion implementation to be a nushell external completer 2022-11-26 14:39:29 -08:00
Jack Wright
9f4bdb8eb8 'Completions for nushell' 2022-11-15 12:30:11 -08:00
Brian Pursley
6b0bd3076c
fix: don't remove flag value that matches subcommand name (#1781)
When the command searches args to find the arg matching a
particular subcommand name, it needs to ignore flag values,
as it is possible that the value for a flag might match
the name of the sub command.

This change improves argsMinusFirstX() to ignore flag values
when it searches for the X to exclude from the result.
2022-11-07 23:12:02 -05:00
mike76-dev
cc7e235fc2
Add Sia to projects using Cobra (#1844) 2022-11-01 09:15:28 -04:00
Marc Khouzam
10cf7be997
Check for group presence after full initialization (#1839)
Fixes #1831

By moving the check for help group existence to "ExecuteC()" we no
longer need groups to be added before AddCommand() is called.  This
provides more flexibility to developers and works better with the use
of "init()" for command creation.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2022-10-24 11:11:57 -04:00
doniacld
4b9d00dfec
Replace deprecated ExactValidArgs with MatchAll in user_guide and shell_completions example (#1836) 2022-10-20 16:33:37 -04:00
Ville Skyttä
badcce14f8
style(bash-v2): various cleanups (#1702)
* use arithmetic evaluation in numeric context

* remove unnecessary $ from array index variables

* [[ ]] over [ ], == over =, remove unnecessary quoting

* use ${foo-} rather than ${foo:-} in emptiness check

The result of the expansion is null no matter if the variable is unset
or null in both cases; the former form is arguably easier on the eye.

* remove unnecessary trailing linefeed removal

No longer needed as of f464d6c82e, saves
a subshell.

* use herestring in activehelp extraction

Herestrings read cleaner than process substitutions, and work in posix
mode (but we do and will have some process substitutions so this doesn't
matter much). Both approaches may end up using temporary files.
2022-10-17 15:24:27 -04:00
Fabian Kammel
1424b7b927
Add Constellation to projects using cobra. (#1829) 2022-10-13 09:47:58 -04:00
Gustavo Bazan
860791844e
feat: make InitDefaultCompletionCmd public (#1467)
* feat: make InitDefaultCompletionCmd public

* PR comments

* Update man_docs_test.go

* Update README.md
2022-10-10 19:06:30 -04:00
aawsome
2169adb574
Add groups for commands in help (#1003)
* Add tests for grouping commands
* Adds Additional Command section in help

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
Co-authored-by: Marc Khouzam <marc.khouzam@gmail.com>
2022-10-10 14:59:11 -06:00
Marc Khouzam
212ea40783
Include --help and --version flag in completion (#1813)
Fixes #1786

The --help, -h, --version and -v flags are normally added when the
`execute()` function is called on a command.  When doing completion
we don't call `execute()` so we need to add these flags explicitly to
the command being completed.

Also, we disable all further completions if the 'help' or 'version'
flags are present on the command-line.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2022-10-04 16:41:30 -06:00
Marc Khouzam
d4040ad8db
Allow user to add completion for powershell alias (#1621)
When a user has an alias in powershell, she will need to register that
alias for completion.  To make that possible, we store the completion
logic into a scriptblock variable which can easily be accessed by the
user to register aliases.

For example, if the user defines an alias for `helm`:
   PS> sal h helm
she will need to register the alias like so:
   PS> Register-ArgumentCompleter -CommandName 'h' -ScriptBlock $__helmCompleterBlock

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
2022-10-03 13:06:04 -04:00
Varun Sharma
23fc5e099f
ci: add minimum GitHub token permissions for workflows (#1792)
Signed-off-by: Varun Sharma <varunsh@stepsecurity.io>
2022-10-03 08:53:12 -06:00
Yann Soubeyrand
93d1913fb0
Add OnFinalize method (#1788)
This method is the OnInitialize counterpart. Like OnInitialize which allows
loading the configuration before each command is executed, OnFinalize allows
saving the configuration after each command has been executed.
2022-10-03 08:52:50 -06:00
dependabot[bot]
07034fee49
build(deps): bump actions/stale from 5 to 6 (#1815)
Bumps [actions/stale](https://github.com/actions/stale) from 5 to 6.
- [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/v5...v6)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 08:52:25 -06:00
Dima Brusilovsky
3dc9761b36
Add allero to list of projects using cobra (#1819) 2022-10-03 08:52:01 -06:00
Francis Nickels III
7039e1fa21
Add '--version' flag to Help output (#1707) 2022-09-30 14:26:05 -04:00
Skeet WU
fce8d8aeb0
Expose ValidateRequiredFlags and ValidateFlagGroups (#1760) 2022-09-27 06:27:48 -04:00
Marc Khouzam
a281c8b47b
Document option to hide the default completion cmd (#1779)
Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2022-09-16 14:44:28 -06:00
Unai Martinez-Corral
459fc5fce3
ci: add workflow_dispatch (#1387) 2022-09-16 16:23:19 -04:00
Unai Martinez-Corral
6d978a911e
add missing license headers (#1809) 2022-09-16 07:55:56 -04:00
Unai Martinez-Corral
4065a33bfd
ci: use action/setup-go's cache (#1783)
* ci: use action/setup-go's cache
* ci: deprecate Golang 1.14
2022-09-13 21:31:59 -06:00
Marc Khouzam
7e289f46f1
Adjustments to documentation (#1656)
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
2022-09-11 17:48:42 -04:00
Marc Khouzam
fe08012edd
Rename Powershell completion tests (#1803)
The name of the powershell completion test file did not match
the actual powershell file.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2022-09-11 15:04:53 -06:00
Yuval Goldberg
d689184a42
Support for case-insensitive command names (#1802)
Add a global `EnableCaseInsensitive` variable to allow
case-insensitive command names.

The variable supports commands names and aliases globally.

Resolves #1382
2022-09-11 08:25:22 -04:00
Unai Martinez-Corral
70e53f62be
Deprecate ExactValidArgs() and test combinations of args validators (#1643)
* deprecate ExactValidArgs in favour of MatchAll(OnlyValidArgs, ...)
* test combinations of args validators
* adjust docs
2022-09-10 09:33:34 -04:00
John McBride
2e8ba6f308
Use correct stale action exempt- yaml keys (#1800)
Signed-off-by: John McBride <jpmmcbride@gmail.com>
2022-09-07 18:25:01 -06:00
Marc Khouzam
0580724b5f
With go 1.18, we must use go install for a binary (#1726)
The format "go install github.com/kyoh86/richgo@latest" will work with
go 1.16 and higher.  It will not work with go 1.15.  However, since
installing "richgo" is only required for people who want to run the go
tests for the Cobra project itself, I feel it is ok to require go 1.16
or higher in this case.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2022-08-30 08:34:58 -06:00
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