-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (40 loc) · 1.27 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
package main
import (
"github.com/alecthomas/kong"
kongdotenv "github.com/titusjaka/kong-dotenv-go"
"github.com/titusjaka/go-sample/v2/commands"
"github.com/titusjaka/go-sample/v2/internal/infrastructure/kongflag"
)
type App struct {
EnvFile kongdotenv.ENVFileConfig `kong:"optional,name=env-file,help='Path to .env file'"`
Migrate commands.MigrateCmd `kong:"cmd,name=migrate,help='Create a new migration, apply (or rollback) migrations to DB.'"`
Server commands.ServerCmd `kong:"cmd,name=server,default=1,help='Start the HTTP server.'"`
}
var (
serviceName = "go-sample"
Version = "v0.0.1"
GitCommitSHA = "unknown"
GitBranch = "unknown"
)
func main() {
var app App
kCtx := kong.Parse(
&app,
kong.Name(serviceName),
kong.Description(
"Go backend application using a modular project layout.\n"+
"Ready to go REST-API service with a specimen route “snippets”.\n"+
"It also contains some infrastructure code to simplify routine operations.",
),
kong.Vars{
kongflag.ServiceName: serviceName,
kongflag.ServiceVersion: Version,
kongflag.GitCommitSHA: GitCommitSHA,
kongflag.GitBranch: GitBranch,
},
kongflag.WithBuildInfo(),
kongflag.WithVersion(Version),
kongflag.WithDumpEnvs(),
)
kCtx.FatalIfErrorf(kCtx.Run())
}