Commit Graph

1077 Commits

Author SHA1 Message Date
Jack Wright
59726e2b0f fixed a typo 2024-11-30 14:06:56 -08:00
Jack Wright
982ba402cb fix tests 2024-11-30 13:59:41 -08:00
Jack Wright
7006719603 fixing formatting 2024-11-30 13:57:31 -08:00
Jack Wright
8b4aa590bb Added new directive to the list of directives for posterity. 2024-11-30 13:34:39 -08:00
Jack Wright
7eac0e11ae Format with spaces instead of tabs 2024-11-30 13:32:05 -08:00
Jack Wright
e7abbf39a3 rewriting nushell implementation 2024-11-29 12:30:16 -08:00
Jack Wright
29af015b57 "fixed whitespace" 2024-11-29 12:30:16 -08:00
Jack Wright
f963733c4e "Reverted to old version without formatting changes and readded nushell" 2024-11-29 12:30:16 -08:00
Jack Wright
1a69a83abc "Added nushell to list of shell autompletes" 2024-11-29 12:30:16 -08:00
Jack Wright
8cb9728476 Update completions.go
Co-authored-by: Marc Khouzam <marc.khouzam@gmail.com>
2024-11-29 12:30:16 -08:00
Jack Wright
ead0ff3e53 Update completions.go
Co-authored-by: Marc Khouzam <marc.khouzam@gmail.com>
2024-11-29 12:30:16 -08:00
Jack Wright
3bfdd6421f Update completions.go
Co-authored-by: Marc Khouzam <marc.khouzam@gmail.com>
2024-11-29 12:30:16 -08:00
Jack Wright
4c4bde6586 "removing extra lines/whitespace" 2024-11-29 12:30:16 -08:00
Jack Wright
3b016843b9 "fixing completions that contain a /" 2024-11-29 12:30:16 -08:00
Jack Wright
247e8e6b55 "ignoring return value when directive is ShellComp#directiveFilterFileExt" 2024-11-29 12:30:16 -08:00
Jack Wright
d86bac4e34 "fixing oddities with fuzzy searching and bug with active help" 2024-11-29 12:30:16 -08:00
Jack Wright
fa746d4d5a Incorporating pull request feedback
- Fixing completion on full paths
- Fixing completion with equals in flags
- Fixing fuzzy search
- Typos
2024-11-29 12:30:16 -08:00
Jack Wright
37ac7454fb Added a whitelist to add cobra apps to to prevent non-cobra apps from
being excuted
2024-11-29 12:30:16 -08:00
Jack Wright
1324e0c316 Added nushell to the Use: line 2024-11-29 12:30:16 -08:00
Jack Wright
2f276e3014 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
2024-11-29 12:30:16 -08:00
Jack Wright
594faef23f Changed the nushell completion implementation to be a nushell external completer 2024-11-29 12:30:16 -08:00
Jack Wright
a1431b2c57 'Completions for nushell' 2024-11-29 12:30:16 -08:00
Vui Lam
02326d52c0
Fix broken links in active_help.md (#2202)
Small change to fix a couple of broken links in active_help.md

Signed-off-by: Vui Lam <vui.lam@broadcom.com>
2024-11-05 06:19:24 -05:00
Leonhard Stemplinger
5a138f143f
Make Powershell completion script work in constrained mode (#2196)
Creating CompletionResult objects is not allowed in Powershell constrained mode, so return results as strings if constrained mode is enabled

Store results as PsCustomObjects instead of hashtables. This prevents Sort-Object from trying to convert the hashtable to a object, which is blocked in constrained mode.
PsCustomObjects are created using New-Object to work around https://github.com/PowerShell/PowerShell/issues/20767
2024-11-03 19:45:01 -05:00
Maxwel Mazur
3a5efaede9
doc: azion project added to the list of CLIs that use cobra (#2198) 2024-10-16 14:13:47 -04:00
Nir Soffer
5bef9d8d87
Fix --version help and output for plugins (#2180)
* Fix --version help with CommandDisplayNameAnnotation

When setting Command.Version, a --version option is added. The help
message for the --version command did not consider the command display
name:

    Flags:
      -h, --help      help for kubectl plugin
      -v, --version   version for kubectl-plugin

With this change the help test is consistent with other flags:

    Flags:
      -h, --help      help for kubectl plugin
      -v, --version   version for kubectl plugin

* Make command DisplayName() public

This allows using the display name in templates or other code that want
to use the same value.

* Use display name in version template

The version template used `{{.Name}}` but for plugins you want to use
`{{.DisplayName}}` to be consistent with other help output.

With this change will show:

    $ kubectl plugin --version
    kubectl plugin version 1.0.0
2024-10-12 12:08:27 -04:00
Nir Soffer
ff7c561cf7
Improve site formatting (#2183)
* Improve site formatting

- Separate titles with blank lines
- Separate code blocks with blank lines
- Always use ``` blocks for examples
- Use console for console (bash syntax highlighting does work well with
  example command output)
- Start console examples with $ (highlight command and output
  differently and more friendly to other shells users)

* Unify indentation in example project structure

* Use single import line in the trivial examples

When we want to show a minimal example with single import it looks
cleaner and more minimal with a single line.
2024-10-12 11:35:01 -04:00
Ikko Eltociear Ashimine
11ab62158a
docs: update README.md (#2197)
minor fix
2024-10-11 06:40:47 -04:00
Nir Soffer
78bfc837fe
Test also with go 1.23 (#2182) 2024-08-24 19:02:44 -04:00
Nir Soffer
511af59cb3
Replace deprecated ioutil usage (#2181)
Fixing golangci-lint errors[1]:

    Error: SA1019: "io/ioutil" has been deprecated since Go 1.19: As of
    Go 1.16, the same functionality is now provided by package [io] or
    package [os], and those implementations should be preferred in new
    code. See the specific function documentation for details.
    (staticcheck)

[1] https://github.com/spf13/cobra/actions/runs/10535452454/job/29194442289?pr=2180
2024-08-24 07:05:26 -04:00
Gabe Cook
756ba6dad6
fix(completions): Complete map flags multiple times (#2174) 2024-07-28 12:18:07 -04:00
Sebastiaan van Stijn
371ae25d2c
Fix deprecation comment for Command.SetOutput (#2172)
Deprecation comments should be at the start of a paragraph [1], and because
of that have a whitespace above them [2];

> To signal that an identifier should not be used, add a paragraph to its
> doc comment that begins with Deprecated: followed by some information
> about the deprecation (...)

With the whitespace missing, some tools, including pkg.go.dev [3] don't
detect it to be deprecated.

[1]: https://go.dev/wiki/Deprecated
[2]: https://go.dev/doc/comment#paragraphs
[3]: https://pkg.go.dev/github.com/spf13/cobra@v1.8.1#Command.SetOutput

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-16 19:36:29 -04:00
Ville Skyttä
e94f6d0dd9
Address golangci-lint deprecation warnings, enable some more linters (#2152)
* Address golangci-lint linter deprecation warnings

1.59.0 outputs:

WARN [lintersdb] The name "gas" is deprecated. The linter has been renamed to: gosec.
WARN [lintersdb] The linter named "megacheck" is deprecated. It has been split into: gosimple, staticcheck, unused.

* Enable some more linters, address finding
2024-06-01 06:31:11 -04:00
Nir Soffer
8003b74a10
Remove fully inactivated linters (#2148)
* Remove fully inactivated linters

Currently golangci-lint fails with these errors:

ERRO [linters_context] golint: This linter is fully inactivated: it will not produce any reports.
ERRO [linters_context] interfacer: This linter is fully inactivated: it will not produce any reports.
ERRO [linters_context] maligned: This linter is fully inactivated: it will not produce any reports.

I could not find any docs explaining what "fully inactivated" mean, but
based this PR[1] it seems that these linters do nothing now. Removing
the linters fixes this issue without changing linting, as they did not
produce any report.

Looking in the linters docs[2] I did not find a replacement for
"interfacer" and "malinged" linters. "stylecheck" seems to be a
replacement for "golint", but we need to fix the code to enable it.

[1] https://github.com/golangci/golangci-lint/pull/4436
[2] https://golangci-lint.run/usage/linters/

* Add stylecheck linter, replacement for golint

This revealed 2 capitalized error messages.

https://golangci-lint.run/usage/linters/#stylecheck
2024-05-18 22:12:02 -04:00
Nir Soffer
5c2c1d627d
Consistent annotation names (#2140)
Add `Annotation` suffix to the private annotations to allow nicer code
using the constants.

For example one can use the current annotation names as a temporary
variable instead of unclear shortcut. Instead of this:

    rag := flagsFromAnnotation(c, f, requiredAsGroup)
    me := flagsFromAnnotation(c, f, mutuallyExclusive)
    or := flagsFromAnnotation(c, f, oneRequired)

We can use now:

    requiredAsGrop := flagsFromAnnotation(c, f, requiredAsGroupAnnotation)
    mutuallyExclusive := flagsFromAnnotation(c, f, mutuallyExclusiveAnnotation)
    oneRequired := flagsFromAnnotation(c, f, oneRequiredAnnotation)

Example taken from #2105.
2024-05-18 09:41:31 -04:00
dependabot[bot]
5a1acea321
build(deps): bump github.com/cpuguy83/go-md2man/v2 from 2.0.3 to 2.0.4 (#2127) 2024-04-13 02:21:03 +00:00
Xinwei Xiong
0fc86c2ffd
docs: update user guide (#2128) 2024-04-08 06:47:35 -04:00
Ville Skyttä
6b5f577ebc
More linting (#2099)
* Address gocritic findings, enable it

* Enable gosimple, no new findings to address
2024-04-01 08:42:08 -04:00
Pedro Mota
bd914e58d6
fix: remove deprecated io/ioutils package (#2120)
ioutils.ReadAll is deprecated since Go 1.16. This commit replaces it with
io.ReadAll. See https://pkg.go.dev/io/ioutil\#ReadAll for reference

Issue #2119
2024-03-12 06:42:46 -04:00
racerole
1f80fa2e23
chore: remove repetitive words (#2122)
Signed-off-by: racerole <jiangyifeng@outlook.com>
2024-03-12 06:40:19 -04:00
damas
c69ae4c36b
ci: test golang 1.22 (#2113) 2024-03-12 06:40:01 -04:00
dependabot[bot]
a30cee5e5a
build(deps): bump actions/cache from 3 to 4 (#2102)
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)

---
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>
2024-03-11 19:36:37 -06:00
dependabot[bot]
f34069ccf5
build(deps): bump golangci/golangci-lint-action from 3.7.0 to 4.0.0 (#2108)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.7.0 to 4.0.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.7.0...v4.0.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>
2024-03-11 19:35:05 -06:00
montag451
bd2655e76c
Add Incus to the list of projects using Cobra (#2118) 2024-03-07 19:36:58 -05:00
Radek Smid
bcfcff729e
Add Taikun CloudWorks to list of projects (#2098) 2024-01-15 08:38:50 -05:00
Dmytro Milinevskyi
4fb0a66a34
flags: clarify documentation that LocalFlags related function do not modify the state (#2064) 2024-01-06 16:49:13 -05:00
Denis
0dec88e793
Add tests for funcs in cobra.go (#2094) 2023-12-30 08:40:15 -05:00
Case Wylie
cbcf75eab9
[chore]: update projects using cobra (#2093)
Signed-off-by: Case Wylie <cmwylie19@defenseunicorns.com>
2023-12-27 21:16:29 -05:00
dependabot[bot]
199b7abe12
build(deps): bump actions/labeler from 4 to 5 (#2086)
* build(deps): bump actions/labeler from 4 to 5

Bumps [actions/labeler](https://github.com/actions/labeler) from 4 to 5.
- [Release notes](https://github.com/actions/labeler/releases)
- [Commits](https://github.com/actions/labeler/compare/v4...v5)

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

* Update labeler configuration for v5

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marc Khouzam <marc.khouzam@gmail.com>
2023-12-23 14:52:45 -05:00
Marc Khouzam
531ce793e3 Remove extra actions/checkout
Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2023-12-23 13:49:43 -05:00