/
completion.go
36 lines (27 loc) · 1007 Bytes
/
completion.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package cmd
import "github.com/spf13/cobra"
var completionCmd = &cobra.Command{
Use: "completion",
Short: "Generate autocompletion for commonly used shells",
Long: `
Completion is used to output completion code for bash and zsh shells.
Before using completion features, you have to source completion code
from your .profile or .bashrc/.zshrc file. This is done by adding
following line to one of above files:
source <(tredctl completion SHELL)
Bash users can as well save it to the file and copy it to:
/etc/bash_completion.d/
Correct arguments for SHELL are: "bash" and "zsh".
Notes:
1) zsh completions requires zsh 5.2 or newer.
2) macOS users have to install bash-completion framework to utilize
completion features. This can be done using homebrew:
brew install bash-completion
Once installed, you must load bash_completion by adding following
line to your .profile or .bashrc/.zshrc:
source $(brew --prefix)/etc/bash_completion
`,
}
func init() {
rootCmd.AddCommand(completionCmd)
}