-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
75 lines (65 loc) · 1.6 KB
/
main.go
File metadata and controls
75 lines (65 loc) · 1.6 KB
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
69
70
71
72
73
74
75
package main
import (
"context"
"log"
"os"
"runtime/debug"
"github.com/carlmjohnson/versioninfo"
"github.com/urfave/cli/v3"
)
func main() {
if err := cmd.Run(context.Background(), os.Args); err != nil {
log.Fatal(err)
}
}
var cmd = &cli.Command{
Name: "device-admin",
Version: toolVersion,
Usage: "Provides a web browser interface for system administration",
Commands: []*cli.Command{
serverCmd,
sidecarCmd,
},
}
// Versioning
const (
// fallbackVersion is the version reported which the Forklift tool reports itself as if its actual
// version is unknown.
fallbackVersion = "dev"
)
var (
toolVersion = determineVersion(buildSummary, fallbackVersion)
// buildSummary should be overridden by ldflags, such as with GoReleaser's "Summary".
buildSummary = ""
)
// determineVersion returns either a semver, a pseudoversion, or a Git hash based on information
// available from Go's `debug.ReadBuildInfo()`.
func determineVersion(override, fallback string) string {
if override != "" {
return override
}
const dirtySuffix = "-dirty"
// Determine any version tags, if available
if info, ok := debug.ReadBuildInfo(); ok &&
info.Main.Version != "" && info.Main.Version != "(devel)" {
v := info.Main.Version
if versioninfo.DirtyBuild {
v += dirtySuffix
}
return v
}
if v := versioninfo.Version; v != "unknown" && v != "(devel)" {
if versioninfo.DirtyBuild {
v += dirtySuffix
}
return v
}
// Fall back to whatever is available
if r := versioninfo.Revision; r != "unknown" && r != "" {
if versioninfo.DirtyBuild {
r += dirtySuffix
}
return r
}
return fallback
}