Skip to content

Commit 14bdf17

Browse files
committed
Add version flag
1 parent 0ea90c5 commit 14bdf17

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ var (
8585
tlsCert string
8686
tlsKey string
8787
users map[string]string
88+
version bool
89+
build string
8890
)
8991

9092
var pledges = "stdio wpath rpath cpath tty inet dns unveil"
@@ -103,6 +105,7 @@ func init() {
103105
flag.StringVar(&passPath, "htpass", fmt.Sprintf("%s/.htpasswd", dir), "Path to .htpasswd file..")
104106
flag.StringVar(&auth, "auth", "basic", "Enable HTTP Basic Authentication.")
105107
flag.BoolVar(&genHtpass, "gen", false, "Generate a .htpasswd file or add a new entry to an existing file.")
108+
flag.BoolVar(&version, "v", false, "Show version and exit.")
106109
flag.Parse()
107110

108111
// These are OpenBSD specific protections used to prevent unnecessary file access.
@@ -177,7 +180,10 @@ func prompt(prompt string, secure bool) (string, error) {
177180
}
178181

179182
func main() {
180-
183+
if version {
184+
fmt.Println(build)
185+
os.Exit(0)
186+
}
181187
if genHtpass {
182188
user, err := prompt("Username: ", false)
183189
if err != nil {

0 commit comments

Comments
 (0)