You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the work, it's brilliant! My main part of code would be like
func init() {
o := &DebugOptions{}
validArgs := []string{"networkchaos", "stresschaos"}
var debugCmd = &cobra.Command{
Use: `debug (CHAOSTYPE) [-c CHAOSNAME] [-n NAMESPACE]`,
Short: `Print the debug information for certain chaos`,
Long: `Print the debug information for certain chaos`
}
debugCmd.Flags().StringVarP(&o.Namespace, "namespace", "n", "default", "namespace to find chaos")
if err := flagCompletion(debugCmd); err != nil {
log.Fatal(err)
}
rootCmd.AddCommand(debugCmd)
}
And I use the default template for completion.go in shell-completion
So there would be two part of completion, one for noun and another one for flags. Both were tested correctly using debug like
And since I'm using zsh, I do source <(chaosctl completion zsh) to activate completion. But when I really use it, the completion would just showing files and dirs, so it seems not working. However when I use the same method to activate completion for helm, everything works fine.
Is there any way to test if completion is working?
cobra version: v1.1.0
The text was updated successfully, but these errors were encountered:
Hi @Yiyiyimu.
The standard Cobra zsh completion does not support sourcing the script because zsh does not recommend that approach. What you must do is store the script under a directory that is in you $fpath.
As for Helm, it extends the script to support source to remain backwards compatible (one extra line). You can try doing it by hand.
In your shell, run: compdef _chaosctl chaosctl
Then completion should work.
Hi community,
Thanks for the work, it's brilliant! My main part of code would be like
And I use the default template for completion.go in shell-completion
So there would be two part of completion, one for noun and another one for flags. Both were tested correctly using debug like
And since I'm using zsh, I do
source <(chaosctl completion zsh)
to activate completion. But when I really use it, the completion would just showing files and dirs, so it seems not working. However when I use the same method to activate completion for helm, everything works fine.Is there any way to test if completion is working?
cobra version: v1.1.0
The text was updated successfully, but these errors were encountered: