MCPcopy Index your code
hub / github.com/rilldata/rill / completionCmd

Function completionCmd

cli/cmd/completion.go:11–61  ·  view source on GitHub ↗

See: https://github.com/spf13/cobra/blob/main/shell_completions.md

(ch *cmdutil.Helper)

Source from the content-addressed store, hash-verified

9
10// See: https://github.com/spf13/cobra/blob/main/shell_completions.md
11func completionCmd(ch *cmdutil.Helper) *cobra.Command {
12 return &cobra.Command{
13 Use: "completion [bash|zsh|fish|powershell]",
14 Short: "Generate completion script for your shell",
15 Long: `To load completions:
16Bash:
17 $ source <(rill completion bash)
18 # To load completions for each session, execute once:
19 # Linux:
20 $ rill completion bash > /etc/bash_completion.d/rill
21 # macOS:
22 $ rill completion bash > /usr/local/etc/bash_completion.d/rill
23Zsh:
24 # If shell completion is not already enabled in your environment,
25 # you will need to enable it. You can execute the following once:
26 $ echo "autoload -U compinit; compinit" >> ~/.zshrc
27 # To load completions for each session, execute once:
28 $ rill completion zsh > "${fpath[1]}/_rill"
29 # You will need to start a new shell for this setup to take effect.
30fish:
31 $ rill completion fish | source
32 # To load completions for each session, execute once:
33 $ rill completion fish > ~/.config/fish/completions/rill.fish
34PowerShell:
35 PS> rill completion powershell | Out-String | Invoke-Expression
36 # To load completions for every new session, run:
37 PS> rill completion powershell > rill.ps1
38 # and source this file from your PowerShell profile.
39`,
40 DisableFlagsInUseLine: true,
41 Hidden: !ch.IsDev(),
42 ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
43 Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
44 RunE: func(cmd *cobra.Command, args []string) error {
45 var err error
46
47 switch args[0] {
48 case "bash":
49 err = cmd.Root().GenBashCompletion(os.Stdout)
50 case "zsh":
51 err = cmd.Root().GenZshCompletion(os.Stdout)
52 case "fish":
53 err = cmd.Root().GenFishCompletion(os.Stdout, true)
54 case "powershell":
55 err = cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
56 }
57
58 return err
59 },
60 }
61}

Callers 1

RootCmdFunction · 0.85

Calls 2

RootMethod · 0.65
IsDevMethod · 0.45

Tested by

no test coverage detected