MCPcopy Create free account
hub / github.com/caarlos0/tasktimer / newCompletionCmd

Function newCompletionCmd

internal/cmd/completion.go:9–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7}
8
9func newCompletionCmd() *completionCmd {
10 cmd := &cobra.Command{
11 Use: "completion [bash|zsh|fish]",
12 Short: "Print shell autocompletion scripts for tt",
13 Long: `To load completions:
14Bash:
15 $ source <(tt completion bash)
16 # To load completions for each session, execute once:
17 Linux:
18 $ tt completion bash > /etc/bash_completion.d/tt
19 MacOS:
20 $ tt completion bash > /usr/local/etc/bash_completion.d/tt
21Zsh:
22 # If shell completion is not already enabled in your environment you will need
23 # to enable it. You can execute the following once:
24 $ echo "autoload -U compinit; compinit" >> ~/.zshrc
25 # To load completions for each session, execute once:
26 $ tt completion zsh > "${fpath[1]}/_tt"
27 # You will need to start a new shell for this setup to take effect.
28Fish:
29 $ tt completion fish | source
30 # To load completions for each session, execute once:
31 $ tt completion fish > ~/.config/fish/completions/tt.fish
32`,
33 SilenceUsage: true,
34 DisableFlagsInUseLine: true,
35 Hidden: true,
36 ValidArgs: []string{"bash", "zsh", "fish"},
37 Args: cobra.ExactValidArgs(1),
38 RunE: func(cmd *cobra.Command, args []string) error {
39 var err error
40 switch args[0] {
41 case "bash":
42 err = cmd.Root().GenBashCompletion(cmd.OutOrStdout())
43 case "zsh":
44 err = cmd.Root().GenZshCompletion(cmd.OutOrStdout())
45 case "fish":
46 err = cmd.Root().GenFishCompletion(cmd.OutOrStdout(), true)
47 }
48 return err
49 },
50 }
51 return &completionCmd{cmd: cmd}
52}

Callers 1

newRootCmdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected