-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (42 loc) · 888 Bytes
/
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
package main
import (
"os"
"github.com/spf13/cobra"
"github.com/nicklasfrahm/infrastructure/cmd/ic/zone"
)
var version = "dev"
var help bool
var rootCmd = &cobra.Command{
Use: "ic",
Short: "A CLI to manage infrastructure",
Long: ` _
(_) ___
| |/ __|
| | (__
|_|\___|
ic is a CLI to manage infrastructure. It provides
a variety of commands to manage different stages
of the infrastructure lifecycle.`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if help {
cmd.Help()
os.Exit(0)
}
},
RunE: func(cmd *cobra.Command, args []string) error {
cmd.Help()
os.Exit(1)
return nil
},
Version: version,
SilenceUsage: true,
}
func init() {
rootCmd.PersistentFlags().BoolVarP(&help, "help", "h", false, "Print this help")
rootCmd.AddCommand(zone.Command)
}
func main() {
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}