-
Notifications
You must be signed in to change notification settings - Fork 0
/
completion.go
41 lines (29 loc) · 1.03 KB
/
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
37
38
39
40
41
package cmd
import (
"strings"
"github.com/spf13/cobra"
)
var completionCmd = &cobra.Command{
Use: "completion",
Short: "Generate auto-completion scripts for common shells",
Long: strings.TrimSpace(`
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 <(%%BINARY_NAME%% 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)
}