-
Notifications
You must be signed in to change notification settings - Fork 0
/
completion.go
35 lines (28 loc) · 922 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
package cmd
import (
"os"
"./utils"
"github.com/spf13/cobra"
)
var newCompletionCmd = &cobra.Command{
Use: "completion",
Short: "Generate bash completion script for fidipides cli",
Long: `Generate bash completion code for fidipides
To use it:
$ source <(fidipides completion)
Then you'll have completion for all the basic fidipides commands. You may want
to add that line to your ~/.bash_profile or ~/.bashrc so that it runs
automatically after you login.
Make sure to have the bash-completion package installed. If you're on OS X also
pay attention to your bash version: it must be >= 4.0, which can be installed
by brew/ports and changed on your terminal emulator of preference.
`,
Run: func(cmd *cobra.Command, args []string) {
if err := cmd.Root().GenBashCompletion(os.Stdout); err != nil {
utils.PrintErrorAndExit(err.Error())
}
},
}
func init() {
RootCmd.AddCommand(newCompletionCmd)
}