-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.go
40 lines (35 loc) · 1.11 KB
/
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
33
34
35
36
37
38
39
40
package cmd
import (
"github.com/spf13/cobra"
"os"
)
// RootCmd the cobra root command
var RootCmd = &cobra.Command{
Use: "zcloud",
Short: "a CLI app for openstack client",
Long: `zcloud is a CLI app for openstack client.
This application is created for speeding up the daily operation on cloud servers on openstack
`,
}
var (
// Verbose flag set to show detail message
Verbose bool
// Host is openstack serivce host
Host string
// Username is the name of user in openstack
Username string
// Password is the password of user in openstack
Password string
)
func errOutput(cmd *cobra.Command, msg interface{}) {
cmd.Println("Error:", msg)
os.Exit(-1)
}
func init() {
RootCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "verbose output")
RootCmd.PersistentFlags().StringVarP(&Host, "host", "", "", "openstack auth service host")
RootCmd.MarkPersistentFlagRequired("host")
RootCmd.PersistentFlags().StringVarP(&Username, "username", "", "", "openstack user's name")
RootCmd.PersistentFlags().StringVarP(&Password, "password", "", "", "openstack user's name")
RootCmd.AddCommand(ServerCmd)
}