diff --git a/internal/server/server.go b/internal/server/server.go index 57dff1f..3981fed 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -10,7 +10,11 @@ import ( ) var ( - pwd string + pwd string + BuildVersion = "" + BuildCommit = "" + BuildDate = "" + BuiltBy = "" ) func init() { @@ -39,11 +43,19 @@ func Start(opts Options) error { r.GET("/stats", func(c *gin.Context) { _, err := os.Stat(pwd + "/profile.sav") c.JSON(200, &struct { - Pwd string `json:"pwd"` - HasProfile bool `json:"hasProfile"` + Pwd string `json:"pwd"` + HasProfile bool `json:"hasProfile"` + BuildVersion string `json:"buildVersion"` + BuildCommit string `json:"buildCommit"` + BuildDate string `json:"buildDate"` + BuiltBy string `json:"builtBy"` }{ - Pwd: pwd, - HasProfile: err == nil && !os.IsNotExist(err), + Pwd: pwd, + HasProfile: err == nil && !os.IsNotExist(err), + BuildVersion: BuildVersion, + BuildCommit: BuildCommit, + BuildDate: BuildDate, + BuiltBy: BuiltBy, }) }) diff --git a/main.go b/main.go index 9ea2776..281e5eb 100644 --- a/main.go +++ b/main.go @@ -17,10 +17,22 @@ package main import ( "github.com/cfi2017/bl3-save/cmd" + "github.com/cfi2017/bl3-save/internal/server" "github.com/spf13/cobra" ) +var ( + version = "v0.0.0-dev" + commit = "" + date = "" + builtBy = "local" +) + func main() { + server.BuildVersion = version + server.BuildCommit = commit + server.BuildDate = date + server.BuiltBy = builtBy cobra.MousetrapHelpText = "" cmd.Execute() }