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>
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>
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
* 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
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>
* 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!
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>
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.
* 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.
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>
* 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>
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>
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