forked from bpicode/fritzctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
completion_bash.go
35 lines (30 loc) · 948 Bytes
/
completion_bash.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
package cmd
import (
"os"
"github.com/spf13/cobra"
)
var completionBashCmd = &cobra.Command{
Use: "bash",
Short: "Outputs fritzctl shell completion for the given shell (bash)",
Long: `Outputs fritzctl shell completion for the given shell (bash)
This depends on the bash-completion binary. Example installation instructions:
OS X:
$ brew install bash-completion
$ source $(brew --prefix)/etc/bash_completion
$ fritzctl completion bash > ~/.fritzctl-completion
$ source ~/.fritzctl-completion
Ubuntu:
$ apt-get install bash-completion
$ source /etc/bash-completion
$ source <(fritzctl completion bash)
Additionally, you may want to output completion to a file and source in your .bashrc`,
Example: "fritzctl completion bash",
RunE: completionBash,
}
func init() {
completionCmd.AddCommand(completionBashCmd)
}
func completionBash(cmd *cobra.Command, args []string) error {
RootCmd.GenBashCompletion(os.Stdout)
return nil
}