-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (29 loc) · 688 Bytes
/
main.go
File metadata and controls
35 lines (29 loc) · 688 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
package main
import (
"os"
"runtime/debug"
"github.com/kunchenguid/treehouse/cmd"
"github.com/kunchenguid/treehouse/internal/updater"
)
var version = ""
func init() {
if version == "" {
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "" && info.Main.Version != "(devel)" {
version = info.Main.Version
} else {
version = "dev"
}
}
}
func main() {
// Handle --update-check before Cobra: the background child process
// bypasses the normal command flow.
if len(os.Args) >= 2 && os.Args[1] == "--update-check" {
updater.RunBackgroundCheck(os.Args[2:])
return
}
cmd.SetVersion(version)
if err := cmd.Execute(); err != nil {
os.Exit(1)
}
}