added cli flag for specifying config

This commit is contained in:
2026-04-20 18:56:22 -06:00
parent ba7edf05a0
commit 727e9f40af
2 changed files with 12 additions and 1 deletions
+11 -1
View File
@@ -1,6 +1,7 @@
package main
import (
"flag"
"log"
"net/http"
@@ -13,7 +14,16 @@ type Server struct {
}
func main() {
cfg, err := ReadConfig("/etc/pkgstash/pkgstash.toml")
// set config from flag if available
var configPath string
flag.StringVar(&configPath, "config", "", "path to config file")
flag.Parse()
if len(configPath) == 0 {
configPath = "/etc/pkgstash/pkgstash.toml"
}
cfg, err := ReadConfig(configPath)
if err != nil {
log.Fatal(err)
}