/
root.go
32 lines (25 loc) · 765 Bytes
/
root.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
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
// holds value of "profile" flag
var rootPprofileName string
// RootCmd defines 'Cloud Automator(ca)' command
var RootCmd = &cobra.Command{
Use: "ca",
Short: "Cloud Automator(CA) command",
Long: `A command line tool to invoke Cloud Automator(CA) API`,
SilenceErrors: true,
SilenceUsage: true,
}
func init() {
cobra.OnInitialize(initRootConfig)
RootCmd.PersistentFlags().StringVarP(&rootPprofileName, "profile", "p", getProfileName(), "Specify profile name")
}
func initRootConfig() {
if _, err := getConfig(); err != nil {
fmt.Printf("Can't read config: %s\n\n", err)
// fmt.Print("Please execute the 'configure' command first to register the profile\n\n")
}
}