This repository has been archived by the owner on Aug 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
75 lines (62 loc) · 1.56 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
import (
"encoding/json"
"io"
"os"
"runtime/debug"
"strings"
"github.com/kraudcloud/cli/api"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var log = logrus.New()
var USER_CONTEXT string
var OUTPUT_FORMAT string
func main() {
root := cobra.Command{
Use: "kra [command]",
Short: "kraud api command line interface",
Version: api.Version,
}
root.AddCommand(feedsCMD())
root.AddCommand(appsCMD())
root.AddCommand(loginCMD())
root.AddCommand(domainsCMD())
root.AddCommand(usersCMD())
root.AddCommand(imagesCMD())
root.AddCommand(layersCMD())
root.AddCommand(imagePushCMD())
root.AddCommand(setupCMD())
root.AddCommand(eventsCMD())
root.AddCommand(tokenCMD())
root.AddCommand(idpCMD())
root.AddCommand(podsCMD())
root.AddCommand(psCMD())
root.AddCommand(volumesCMD())
root.AddCommand(podLogs())
root.AddCommand(UpCMD())
root.AddCommand(namespacesCMD())
root.AddCommand(vpcsCMD())
root.AddCommand(vpcOverlaysCMD())
root.AddCommand(inflowsCMD())
root.PersistentFlags().StringVarP(&USER_CONTEXT, "context", "c", "default", "user context")
root.PersistentFlags().StringVarP(&OUTPUT_FORMAT, "output", "o", "table", "output format (table, json)")
defer func() {
if r := recover(); r != nil {
if err, ok := r.(error); ok {
if strings.Contains(err.Error(), "runtime error:") {
log.Error(r)
debug.PrintStack()
os.Exit(1)
}
}
log.Fatal(r)
}
}()
root.Execute()
}
func identJSONEncoder(w io.Writer, data any) error {
enc := json.NewEncoder(w)
enc.SetIndent("", " ")
return enc.Encode(data)
}