forked from jamessoubry/consul-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
52 lines (41 loc) · 821 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
51
52
package main
import (
"log"
"os"
"github.com/mitchellh/cli"
)
const (
version = "0.2.0"
)
func main() {
os.Exit(realMain())
}
// Just our main function to kick things off in a loop.
func realMain() int {
args := os.Args[1:]
for _, arg := range args {
if arg == "-v" || arg == "-version" || arg == "--version" {
newArgs := make([]string, len(args)+1)
newArgs[0] = "version"
copy(newArgs[1:], args)
args = newArgs
break
}
}
cli := &cli.CLI{
Args: args,
Commands: Commands,
HelpFunc: cli.FilteredHelpFunc(
CommandsInclude, cli.BasicHelpFunc("consul-snapshot")),
HelpWriter: os.Stdout,
}
exitCode, err := cli.Run()
if err != nil {
log.Fatalf("Error executing CLI: %s", err.Error())
return 1
}
return exitCode
}
func formattedVersion() string {
return version
}