-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
48 lines (40 loc) · 1 KB
/
main.go
File metadata and controls
48 lines (40 loc) · 1 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
package main
import (
"fmt"
"log"
"os"
"runtime/debug"
"github.com/UnitVectorY-Labs/authservicecentral/internal/cmd"
)
// Version is the application version, injected at build time via ldflags
var Version = "dev"
func main() {
// Set the build version from the build info if not set by the build system
if Version == "dev" || Version == "" {
if bi, ok := debug.ReadBuildInfo(); ok {
if bi.Main.Version != "" && bi.Main.Version != "(devel)" {
Version = bi.Main.Version
}
}
}
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "usage: authservicecentral <command> [flags]\n\ncommands:\n run Start the server\n migrate Run database migrations\n version Print version\n")
os.Exit(1)
}
var err error
switch os.Args[1] {
case "run":
err = cmd.Run(os.Args[2:])
case "migrate":
err = cmd.Migrate(os.Args[2:])
case "version":
fmt.Println(Version)
return
default:
fmt.Fprintf(os.Stderr, "unknown command: %s\n", os.Args[1])
os.Exit(1)
}
if err != nil {
log.Fatal(err)
}
}