Skip to content

Commit

Permalink
fix: remove extra completion cmd
Browse files Browse the repository at this point in the history
Cobra by default provides completions for us, there is no need to define one.
  • Loading branch information
aymanbagabas authored and maaslalani committed Aug 1, 2023
1 parent 99f44cc commit 68ec042
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,37 +157,14 @@ var (
CommitSHA string
)

// CompletionCmd is the cobra command for generating completion scripts.
var CompletionCmd = &cobra.Command{
Use: "completion [bash|zsh|fish|powershell]",
Short: "Generate completion script",
Long: `To load completions`,
DisableFlagsInUseLine: true,
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
RunE: func(cmd *cobra.Command, args []string) error {
switch args[0] {
case "bash":
return rootCmd.GenBashCompletion(os.Stdout)
case "zsh":
return rootCmd.GenZshCompletion(os.Stdout)
case "fish":
return rootCmd.GenFishCompletion(os.Stdout, true)
case "powershell":
return rootCmd.GenPowerShellCompletion(os.Stdout)
}
return nil
},
}

// ManCmd is the cobra command for the manual.
var ManCmd = &cobra.Command{
Use: "man",
Short: "Generate man page",
Long: `To generate the man page`,
Args: cobra.NoArgs,
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
page, err := mcobra.NewManPage(1, rootCmd) // .
if err != nil {
return err
Expand All @@ -200,7 +177,7 @@ var ManCmd = &cobra.Command{
}

func init() {
rootCmd.AddCommand(CompletionCmd, ManCmd)
rootCmd.AddCommand(ManCmd)

rootCmd.Flags().StringSliceVar(&bcc, "bcc", []string{}, "BCC recipients")
rootCmd.Flags().StringSliceVar(&cc, "cc", []string{}, "CC recipients")
Expand Down

0 comments on commit 68ec042

Please sign in to comment.