-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
root.go
47 lines (39 loc) · 954 Bytes
/
root.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
42
43
44
45
46
47
package cmd
import (
"log"
"os"
"github.com/aryansharma9917/Codewise-CLI/cmd/docker"
"github.com/aryansharma9917/Codewise-CLI/cmd/kubernetes"
"github.com/spf13/cobra"
)
// rootCmd is the root command for Codewise-CLI
var rootCmd = &cobra.Command{
Use: "Codewise-CLI [command]",
Short: "Do all your tedious tasks with a single command",
Run: func(cmd *cobra.Command, args []string) {
err := cmd.Help()
checkNilErr(err)
},
}
func Execute() {
rootCmd.CompletionOptions.DisableDefaultCmd = true
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
func init() {
// Subcommands for the root command
rootCmd.AddCommand(encodeCmd)
rootCmd.AddCommand(versionCmd)
rootCmd.AddCommand(yamlToJsonCmd)
rootCmd.AddCommand(jsonToYamlCmd)
rootCmd.AddCommand(docker.DockerCmd)
rootCmd.AddCommand(keyValueToJsonCmd)
rootCmd.AddCommand(kubernetes.KubernetesCmd)
}
func checkNilErr(err error) {
if err != nil {
log.Fatal(err)
}
}