mirror of
https://github.com/sstent/go-garth-cli.git
synced 2026-01-25 16:42:48 +00:00
39 lines
802 B
Go
39 lines
802 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
completionCmd := &cobra.Command{
|
|
Use: "completion",
|
|
}
|
|
rootCmd.AddCommand(completionCmd)
|
|
|
|
completionBashCmd := &cobra.Command{
|
|
Use: "bash",
|
|
Short: "Output command completion for Bourne Again Shell (bash)",
|
|
RunE: completionBash,
|
|
Args: cobra.NoArgs,
|
|
}
|
|
completionCmd.AddCommand(completionBashCmd)
|
|
|
|
completionZshCmd := &cobra.Command{
|
|
Use: "zsh",
|
|
Short: "Output command completion for Z Shell (zsh)",
|
|
RunE: completionZsh,
|
|
Args: cobra.NoArgs,
|
|
}
|
|
completionCmd.AddCommand(completionZshCmd)
|
|
}
|
|
|
|
func completionBash(_ *cobra.Command, _ []string) error {
|
|
return rootCmd.GenBashCompletion(os.Stdout)
|
|
}
|
|
|
|
func completionZsh(_ *cobra.Command, _ []string) error {
|
|
return rootCmd.GenZshCompletion(os.Stdout)
|
|
}
|