-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
45 lines (39 loc) · 978 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
package main
import (
"fmt"
"os"
"runtime/debug"
"github.com/mworzala/mc/cmd/mc"
"github.com/mworzala/mc/internal/pkg/cli"
)
var (
version = "dev"
commit = "none"
date = "unknown"
modified = false
source = "no"
)
func main() {
//goland:noinspection GoBoolExpressions version is set using ldflags
if version == "dev" {
// Not built with goreleaser, so we should try to read go build info
if buildInfo, ok := debug.ReadBuildInfo(); ok {
for _, setting := range buildInfo.Settings {
switch setting.Key {
case "vcs.revision":
commit = setting.Value
case "vcs.time":
date = setting.Value
case "vcs.modified":
modified = setting.Value != "false"
}
}
}
}
app := cli.NewApp(cli.BuildInfo{Version: version, Commit: commit, Date: date, Modified: modified, Source: source == "yes"})
rootCmd := mc.NewRootCmd(app)
if err := rootCmd.Execute(); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}