-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (52 loc) · 2.2 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
package main
import (
"log"
"os"
_ "github.com/alphauslabs/blue-sdk-go/api"
"github.com/alphauslabs/bluectl/cmds"
"github.com/alphauslabs/bluectl/params"
"github.com/alphauslabs/bluectl/pkg/logger"
"github.com/spf13/cobra"
)
var (
rootCmd = &cobra.Command{
Use: "bluectl",
Short: "Command line interface for Alphaus services",
Long: `Command line interface for Alphaus services.
The general form is bluectl <resource[ subresource...]> <action> [flags]. Most commands support the --raw-input
flag to be always in sync with the current feature set of the API in case the built-in flags don't support all
the possible input combinations. For beta APIs, we recommend you to use the --raw-input flag. See
https://alphauslabs.github.io/blueapidocs/ for the latest API reference.`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if params.CleanOut {
logger.SetPrefix(logger.PrefixNone)
}
},
Run: func(cmd *cobra.Command, args []string) {
logger.Info("see -h for more information")
},
}
)
func init() {
rootCmd.Flags().SortFlags = false
rootCmd.PersistentFlags().SortFlags = false
rootCmd.PersistentFlags().StringVar(¶ms.AuthUrl, "auth-url", os.Getenv("ALPHAUS_AUTH_URL"), "authentication URL, defaults to $ALPHAUS_AUTH_URL if set")
rootCmd.PersistentFlags().StringVar(¶ms.ClientId, "client-id", os.Getenv("ALPHAUS_CLIENT_ID"), "your client id, defaults to $ALPHAUS_CLIENT_ID")
rootCmd.PersistentFlags().StringVar(¶ms.ClientSecret, "client-secret", os.Getenv("ALPHAUS_CLIENT_SECRET"), "your client secret, defaults to $ALPHAUS_CLIENT_SECRET")
rootCmd.PersistentFlags().StringVar(¶ms.OutFile, "out", params.OutFile, "output file, if the command supports writing to file")
rootCmd.PersistentFlags().StringVar(¶ms.OutFmt, "outfmt", "csv", "output format: json, csv, valid if --out is set")
rootCmd.PersistentFlags().BoolVar(¶ms.CleanOut, "bare", params.CleanOut, "if true, set console output to barebones, easier for scripting")
rootCmd.AddCommand(
cmds.AccessTokenCmd(),
cmds.WhoAmICmd(),
cmds.IamUsersCmd(),
cmds.AwsCostCmd(),
cmds.AwsPayerCmd(),
cmds.OpsCmd(),
)
}
func main() {
cobra.EnableCommandSorting = false
log.SetOutput(os.Stdout)
rootCmd.Execute()
}