forked from G-Node/gin-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
68 lines (55 loc) · 1.24 KB
/
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"fmt"
"os"
"strings"
"github.com/G-Node/gin-cli/ginclient/log"
"github.com/G-Node/gin-cli/gincmd"
"github.com/G-Node/gin-cli/git"
)
// Version strings are populated using linker flags //
var (
gincliversion string
build string
commit string
verinfo gincmd.VersionInfo
)
// ================================================ //
func init() {
verinfo.Version = gincliversion
verinfo.Build = build
verinfo.Commit = commit
gitVer, err := git.GetGitVersion()
if err != nil {
gitVer = err.Error()
}
verinfo.Git = gitVer
annexVer, err := git.GetAnnexVersion()
if err != nil {
annexVer = err.Error()
}
verinfo.Annex = annexVer
if err != nil {
fmt.Println("Failed to initialise log file")
}
err = log.Init()
log.Write("VERSION: %s", verinfo.String())
}
func main() {
defer log.Close()
var args = make([]string, len(os.Args))
for idx, a := range os.Args {
args[idx] = a
if strings.Contains(a, " ") {
args[idx] = fmt.Sprintf("'%s'", a)
}
}
log.Write("COMMAND: %s", strings.Join(args, " "))
cwd, _ := os.Getwd()
log.Write("CWD: %s", cwd)
rootCmd := gincmd.SetUpCommands(verinfo)
rootCmd.SetVersionTemplate("{{ .Version }}")
// Engage
rootCmd.Execute()
log.Write("EXIT OK")
}