-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathaccount.go
More file actions
77 lines (69 loc) · 1.7 KB
/
account.go
File metadata and controls
77 lines (69 loc) · 1.7 KB
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
76
77
package cmd
import (
"encoding/json"
"fmt"
"github.com/opslevel/opslevel-go/v2025"
"github.com/opslevel/cli/common"
"github.com/spf13/cobra"
)
var lifecycleCmd = &cobra.Command{
Use: "lifecycle",
Aliases: []string{"lifecycles"},
Short: "Lists lifecycles",
Long: `Lists lifecycles`,
Run: func(cmd *cobra.Command, args []string) {
list, err := getClientGQL().ListLifecycles()
cobra.CheckErr(err)
if isJsonOutput() {
common.JsonPrint(json.MarshalIndent(list, "", " "))
} else {
w := common.NewTabWriter("ALIAS", "ID")
for _, item := range list {
fmt.Fprintf(w, "%s\t%s\t\n", item.Alias, item.Id)
}
w.Flush()
}
},
}
var tierCmd = &cobra.Command{
Use: "tier",
Aliases: []string{"tiers"},
Short: "Lists tiers",
Long: `Lists tiers`,
Run: func(cmd *cobra.Command, args []string) {
list, err := getClientGQL().ListTiers()
cobra.CheckErr(err)
if isJsonOutput() {
common.JsonPrint(json.MarshalIndent(list, "", " "))
} else {
w := common.NewTabWriter("ALIAS", "ID")
for _, item := range list {
fmt.Fprintf(w, "%s\t%s\t\n", item.Alias, item.Id)
}
w.Flush()
}
},
}
var toolsCmd = &cobra.Command{
Use: "tool",
Aliases: []string{"tools"},
Short: "Lists the valid alias for tools",
Long: `Lists the valid alias for tools`,
Run: func(cmd *cobra.Command, args []string) {
list := opslevel.AllToolCategory
if isJsonOutput() {
common.JsonPrint(json.MarshalIndent(list, "", " "))
} else {
w := common.NewTabWriter("NAME")
for _, item := range list {
fmt.Fprintf(w, "%s\t\n", item)
}
w.Flush()
}
},
}
func init() {
listCmd.AddCommand(lifecycleCmd)
listCmd.AddCommand(tierCmd)
listCmd.AddCommand(toolsCmd)
}