-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
52 lines (44 loc) · 821 Bytes
/
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"
"github.com/jgrancell/kubenv/cmd"
"github.com/jgrancell/kubenv/settings"
)
func main() {
Run(os.Args[1:])
}
func Run(args []string) {
version := "1.0.0"
// Loading configuration
conf, err := settings.LoadConfiguration()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if len(args) >= 1 {
var result bool
command := args[0]
switch command {
case "delete":
result, err = cmd.Delete(args[1:], conf)
case "import":
result, err = cmd.Import(args[1:], conf)
case "list":
result, err = cmd.List(conf)
case "use":
result, err = cmd.Activate(args[1:], conf)
default:
result, err = cmd.Help(version)
}
if result {
os.Exit(0)
} else {
fmt.Println(err)
os.Exit(1)
}
} else {
_, _ = cmd.Help(version)
os.Exit(1)
}
}