-
Notifications
You must be signed in to change notification settings - Fork 544
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cmd): fix cobra completion (#3905)
* fix(cmd): fix cobra completion * updates
- Loading branch information
1 parent
f96ab07
commit 18e5fc9
Showing
3 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package ignitecmd | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// completionCmd represents the completion command | ||
func NewCompletionCmd() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "completion [bash|zsh|fish|powershell]", | ||
Short: "Generates shell completion script.", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if len(args) == 0 { | ||
cmd.Help() | ||
os.Exit(0) | ||
} | ||
switch args[0] { | ||
case "bash": | ||
cmd.Root().GenBashCompletion(os.Stdout) | ||
case "zsh": | ||
cmd.Root().GenZshCompletion(os.Stdout) | ||
case "fish": | ||
cmd.Root().GenFishCompletion(os.Stdout, true) | ||
case "powershell": | ||
cmd.Root().GenPowerShellCompletion(os.Stdout) | ||
default: | ||
cmd.Help() | ||
} | ||
}, | ||
} | ||
} |