Use double-hyphen style CLI flags with pflag

This commit is contained in:
Christoph Haas 2026-03-22 21:49:04 +01:00
parent 6ef558d44d
commit 1c9578cb56
3 changed files with 8 additions and 5 deletions

View file

@ -2,7 +2,6 @@ package main
import (
"crypto/rand"
"flag"
"fmt"
"log"
"net/http"
@ -13,13 +12,14 @@ import (
"github.com/imc-vibe/backend/internal/auth"
"github.com/imc-vibe/backend/internal/config"
"github.com/imc-vibe/backend/internal/db"
"github.com/spf13/pflag"
)
func main() {
resetAdminPassword := flag.Bool("reset-admin-password", false, "Reset admin password to a random value and exit")
bind := flag.String("bind", "", "IP address to bind to (default: 0.0.0.0)")
port := flag.String("port", "", "Port to listen on (default: 8080)")
flag.Parse()
resetAdminPassword := pflag.Bool("reset-admin-password", false, "Reset admin password to a random value and exit")
bind := pflag.StringP("bind", "b", "", "IP address to bind to (default: 0.0.0.0)")
port := pflag.StringP("port", "p", "", "Port to listen on (default: 8080)")
pflag.Parse()
cfg := config.Load()