mirror of
https://github.com/k3s-io/k3s.git
synced 2026-02-03 20:39:49 -05:00
* Refac for shell completion Signed-off-by: Vitor Savian <vitor.savian@suse.com> * Change FLAGS to OPTIONS Signed-off-by: Vitor Savian <vitor.savian@suse.com> * Refac bash and zsh func names Signed-off-by: Vitor Savian <vitor.savian@suse.com> * Refac bash and zsh func names Signed-off-by: Vitor Savian <vitor.savian@suse.com> --------- Signed-off-by: Vitor Savian <vitor.savian@suse.com>
38 lines
790 B
Go
38 lines
790 B
Go
package cmds
|
|
|
|
import (
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
func NewCompletionCommand(bash, zsh func(*cli.Context) error) *cli.Command {
|
|
installFlag := cli.BoolFlag{
|
|
Name: "i",
|
|
Usage: "Install source line to rc file",
|
|
}
|
|
|
|
return &cli.Command{
|
|
Name: "completion",
|
|
Usage: "Install shell completion script",
|
|
UsageText: appName + " completion [COMMAND]",
|
|
Subcommands: []*cli.Command{
|
|
{
|
|
Name: "bash",
|
|
Usage: "Bash completion",
|
|
UsageText: appName + " completion bash [OPTIONS]",
|
|
Action: bash,
|
|
Flags: []cli.Flag{
|
|
&installFlag,
|
|
},
|
|
},
|
|
{
|
|
Name: "zsh",
|
|
Usage: "Zsh completion",
|
|
Action: zsh,
|
|
UsageText: appName + " completion zsh [OPTIONS]",
|
|
Flags: []cli.Flag{
|
|
&installFlag,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|