Skip to content

Commit

Permalink
refactor: DeprecatedになったAPIをやめた
Browse files Browse the repository at this point in the history
  • Loading branch information
xztaityozx committed Feb 24, 2023
1 parent d063c9d commit 4de811f
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions cmd/completion.go
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
package cmd

import (
"log"
"os"
"log"
"os"

"github.com/spf13/cobra"
"github.com/spf13/cobra"
)

var completionCmd = &cobra.Command{
Use: "completion [bash|zsh|fish|powershell]",
Short: "Generate completion script",
DisableFlagsInUseLine: true,
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
Args: cobra.ExactValidArgs(1),
Run: func(cmd *cobra.Command, args []string) {
switch args[0] {
case "bash":
err := cmd.Root().GenBashCompletion(os.Stdout)
if err != nil {
log.Fatalln(err)
}
case "zsh":
err := cmd.Root().GenZshCompletion(os.Stdout)
if err != nil {
log.Fatalln(err)
}
case "fish":
err := cmd.Root().GenFishCompletion(os.Stdout, true)
if err != nil {
log.Fatalln(err)
}
case "powershell":
err := cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
if err != nil {
log.Fatalln(err)
}
}
},
Use: "completion [bash|zsh|fish|powershell]",
Short: "Generate completion script",
DisableFlagsInUseLine: true,
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Run: func(cmd *cobra.Command, args []string) {
switch args[0] {
case "bash":
err := cmd.Root().GenBashCompletion(os.Stdout)
if err != nil {
log.Fatalln(err)
}
case "zsh":
err := cmd.Root().GenZshCompletion(os.Stdout)
if err != nil {
log.Fatalln(err)
}
case "fish":
err := cmd.Root().GenFishCompletion(os.Stdout, true)
if err != nil {
log.Fatalln(err)
}
case "powershell":
err := cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
if err != nil {
log.Fatalln(err)
}
}
},
}

func init() {
rootCmd.AddCommand(completionCmd)
completionCmd.SetUsageTemplate(completionCmd.Use)
rootCmd.AddCommand(completionCmd)
completionCmd.SetUsageTemplate(completionCmd.Use)
}

0 comments on commit 4de811f

Please sign in to comment.