From 14bdf17e49fd09b59f021516a22ec9c01615463c Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Fri, 10 Dec 2021 15:50:07 -0700 Subject: [PATCH] Add version flag --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 0e5d32b..6dd4914 100644 --- a/main.go +++ b/main.go @@ -85,6 +85,8 @@ var ( tlsCert string tlsKey string users map[string]string + version bool + build string ) var pledges = "stdio wpath rpath cpath tty inet dns unveil" @@ -103,6 +105,7 @@ func init() { flag.StringVar(&passPath, "htpass", fmt.Sprintf("%s/.htpasswd", dir), "Path to .htpasswd file..") flag.StringVar(&auth, "auth", "basic", "Enable HTTP Basic Authentication.") flag.BoolVar(&genHtpass, "gen", false, "Generate a .htpasswd file or add a new entry to an existing file.") + flag.BoolVar(&version, "v", false, "Show version and exit.") flag.Parse() // These are OpenBSD specific protections used to prevent unnecessary file access. @@ -177,7 +180,10 @@ func prompt(prompt string, secure bool) (string, error) { } func main() { - + if version { + fmt.Println(build) + os.Exit(0) + } if genHtpass { user, err := prompt("Username: ", false) if err != nil {