mirror of
https://github.com/ivuorinen/a.git
synced 2026-01-26 11:34:07 +00:00
Initial commit
This commit is contained in:
27
cmd/completion.go
Normal file
27
cmd/completion.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// Package cmd provides CLI command constructors for the age wrapper.
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Completion returns a cobra.Command that generates shell completions.
|
||||
func Completion(rootCmd *cobra.Command) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "completion [bash|zsh|fish]",
|
||||
Short: "Generate shell completion scripts",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(_ *cobra.Command, args []string) {
|
||||
switch args[0] {
|
||||
case "bash":
|
||||
_ = rootCmd.GenBashCompletion(os.Stdout)
|
||||
case "zsh":
|
||||
_ = rootCmd.GenZshCompletion(os.Stdout)
|
||||
case "fish":
|
||||
_ = rootCmd.GenFishCompletion(os.Stdout, true)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user