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
Replace the current Zsh completion with a Zsh completion solution based
on Go completions. This allows to support custom completions (based
on Go completions), but also to standardize the behavior of completion
across all shells.
Also, add support to Go completions for the bash completion annotations:
BashCompFilenameExt (including Command.MarkFlagFilename() family)
- still supported by zsh
BashCompSubdirsInDir - now supported by zsh
BashCompOneRequiredFlag (including Command.MarkFlagRequired() family)
- now supported by zsh and fish
Finally, remove the suggestin of the = form of flag completion.
The = form is supported, but it will not be suggested to avoid having
duplicated suggestions.
* Don't exclude 'help' from bash completions
Fixes#1000.
* Provide completion for the help command
1- Show 'help' as a possible completion
2- Provide completions for the help command itself
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
Co-authored-by: Zaven Muradyan <voithos@google.com>
When a command request to DisableFlagParsing, it should not fail due
to a missing required flag. In fact, such a check will always fail
since flags weren't parsed!
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
* replace labeler action with periodic-labeler
this replaces the default labeler as it
does not label PRs from forks properly.
with periodic-labeler it should apply labels on
a cron to any PR and resolve the below bug:
https://github.com/spf13/cobra/issues/1092
Since the completion directives will be used for all shells, and that
these names will be consumed by users, this is a more appropriate name.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
This commit allows programs using Cobra to code their custom completions
in Go instead of Bash.
The new ValidArgsFunction field is added for commands, similarly to
ValidArgs. For flags, the new function
Command.RegisterFlagCompletionFunc() is added.
When either of the above functions is used, the bash completion script
will call the new hidden command '__complete', passing it all
command-line arguments. The '__complete' command will call
the function specified by Command.ValidArgsFunction or by
Command.RegisterFlagCompletionFunc to obtain completions from the
program itself.
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
* add support for autolabel stale PR
automatically labels stale PRs
* stale label is kind/stale
updates the stale label to reflect
existing project labels
* adds a relevant stale message
for both PRs and issues there is now a more
descriptive and relevant message
when the action marks something stale
* no auto-close on stale issues/prs
uses the exempt flag to ignore issues already marked
stale. this will allow us to auto label stale,
and then ignore them so they do not get auto
closed.