-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcmd_root.go
More file actions
41 lines (34 loc) · 851 Bytes
/
cmd_root.go
File metadata and controls
41 lines (34 loc) · 851 Bytes
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 yaakcli
import (
"github.com/spf13/cobra"
"os"
)
var CLIVersion string
func rootCmd(v string) *cobra.Command {
CLIVersion = v
var fVersion bool
cmd := &cobra.Command{
Use: "yaakcli",
Short: "Develop plugins for Yaak",
Long: "Generate, build, and debug plugins for Yaak, the most intuitive desktop API client",
Run: func(cmd *cobra.Command, args []string) {
if fVersion {
println(CLIVersion)
os.Exit(0)
}
CheckError(cmd.Help())
},
}
cmd.AddCommand(devCmd)
cmd.AddCommand(buildCmd)
cmd.AddCommand(generateCmd)
cmd.AddCommand(whoamiCmd)
cmd.AddCommand(loginCmd)
cmd.AddCommand(logoutCmd)
cmd.AddCommand(publishCmd)
cmd.Flags().BoolVar(&fVersion, "version", false, "Show the current version of the Yaak CLI")
return cmd
}
func Execute(version string) {
CheckError(rootCmd(version).Execute())
}