forked from Owloops/updo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
44 lines (35 loc) · 884 Bytes
/
Copy pathmain.go
File metadata and controls
44 lines (35 loc) · 884 Bytes
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
package main
import (
"fmt"
"os"
"github.com/Owloops/updo/cmd/aws"
"github.com/Owloops/updo/cmd/monitor"
"github.com/Owloops/updo/cmd/root"
"github.com/spf13/cobra"
)
var (
version = "dev"
commit = "unknown"
date = "unknown"
)
func main() {
versionStr := fmt.Sprintf("%s (commit: %s, built: %s)", version, commit, date)
root.RootCmd.Version = versionStr
root.RootCmd.SetVersionTemplate("updo version {{.Version}}\n")
root.RootCmd.AddCommand(monitor.MonitorCmd)
root.RootCmd.AddCommand(aws.AWSCmd)
root.RootCmd.Run = func(cmd *cobra.Command, args []string) {
if len(args) == 0 && cmd.CalledAs() == "updo" {
monitor.MonitorCmd.Run(cmd, args)
return
}
if err := cmd.Help(); err != nil {
fmt.Fprintf(os.Stderr, "Error displaying help: %v\n", err)
os.Exit(1)
}
}
if err := root.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}