mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
35 lines
930 B
Go
35 lines
930 B
Go
// Copyright 2020 The Kubernetes Authors.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package completion
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func NewCommand() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "completion [bash|zsh|fish|powershell]",
|
|
Short: "Generate shell completion script",
|
|
Long: "Generate shell completion.",
|
|
DisableFlagsInUseLine: true,
|
|
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
|
Args: cobra.ExactValidArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
switch args[0] {
|
|
case "bash":
|
|
return cmd.Root().GenBashCompletion(os.Stdout)
|
|
case "zsh":
|
|
return cmd.Root().GenZshCompletion(os.Stdout)
|
|
case "fish":
|
|
return cmd.Root().GenFishCompletion(os.Stdout, true)
|
|
case "powershell":
|
|
return cmd.Root().GenPowerShellCompletion(os.Stdout)
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
}
|