diff --git a/App.go b/App.go index ef8e698..1a30912 100644 --- a/App.go +++ b/App.go @@ -10,6 +10,8 @@ import ( "sync" ) +var APP_VERSION string = "x.x.x" // Overridden by makefile + type App struct { cfg AppConfig @@ -44,7 +46,7 @@ func NewAppFromConfig(cfg AppConfig) *App { } func (this *App) ServeHTTP(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Server", "webcmd/1.0") + w.Header().Set("Server", "webcmd/"+APP_VERSION) if r.Method == "GET" { if r.URL.Path == "/" { diff --git a/cmd/webcmd/main.go b/cmd/webcmd/main.go index c42376a..a4e9148 100644 --- a/cmd/webcmd/main.go +++ b/cmd/webcmd/main.go @@ -2,15 +2,23 @@ package main import ( "flag" + "fmt" "log" + "os" "code.ivysaur.me/webcmd" ) func main() { confPath := flag.String("config", "webcmd.conf", "Path to configuration file") + versionFlag := flag.Bool("version", false, "Display version number and exit") flag.Parse() + if *versionFlag { + fmt.Println("webcmd/" + webcmd.APP_VERSION) + os.Exit(0) + } + app, err := webcmd.NewApp(*confPath) if err != nil { log.Fatalf(err.Error())