fix: rename envfile flag to env-file with backwards compat

- Update peekOption to accept both env-file and envfile
- Add _ = fs.String("env-file", ...) flag definition
- Update comments to reference env-file
This commit is contained in:
AJ ONeal 2026-08-13 13:10:44 -06:00
parent 71671b7852
commit 92a2df244b
No known key found for this signature in database

View File

@ -108,8 +108,8 @@ func main() {
QueryParamNames: nil, // []string{"access_token", "token"},
}
// Peek for --envfile early
envPath := peekOption(os.Args[1:], []string{"-envfile", "--envfile"}, ".env")
// Peek for --env-file early
envPath := peekOption(os.Args[1:], []string{"-env-file", "--env-file", "-envfile", "--envfile"}, ".env")
_ = godotenv.Load(envPath) // silent if missing
// Override defaults from env
@ -131,6 +131,7 @@ func main() {
// Flags
fs := flag.NewFlagSet(name, flag.ContinueOnError)
_ = fs.String("env-file", "", "path to .env file (or set $AUTHPROXY_ENV_FILE)")
fs.BoolVar(&cli.ShowVersion, "version", false, "show version and exit")
fs.IntVar(&cli.Port, "port", cli.Port, "port to listen on")
fs.StringVar(&cli.Address, "address", cli.Address, "address to bind to (e.g. 127.0.0.1)")