-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
52 lines (43 loc) · 1.06 KB
/
main.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
48
49
50
51
52
package main
import (
"fmt"
"os"
"strings"
"github.com/kubicorn/kubicorn/pkg/logger"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "eksctl",
Short: "a CLI for Amazon EKS",
Run: func(c *cobra.Command, _ []string) {
c.Help()
},
}
func init() {
addCommands()
rootCmd.PersistentFlags().IntVarP(&logger.Level, "verbose", "v", 3, "set log level, use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging")
rootCmd.PersistentFlags().BoolVarP(&logger.Color, "color", "C", true, "toggle colorized logs")
}
func main() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err) // outputs cobra errors
os.Exit(-1)
}
}
func addCommands() {
rootCmd.AddCommand(versionCmd())
rootCmd.AddCommand(createCmd())
rootCmd.AddCommand(deleteCmd())
rootCmd.AddCommand(getCmd())
rootCmd.AddCommand(utilsCmd())
}
func getNameArg(args []string) string {
if len(args) > 1 {
logger.Critical("only one argument is allowed to be used as a name")
os.Exit(1)
}
if len(args) == 1 {
return (strings.TrimSpace(args[0]))
}
return ""
}