Skip to content

Commit

Permalink
Add version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
qbit committed Dec 10, 2021
1 parent 0ea90c5 commit 14bdf17
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 14bdf17

Please sign in to comment.