From 727e9f40af8c318378fb101baeb4ad5bc73c259d Mon Sep 17 00:00:00 2001 From: Eric Phillips Date: Mon, 20 Apr 2026 18:56:22 -0600 Subject: [PATCH] added cli flag for specifying config --- TODO.md | 1 + main.go | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index c4b0c19..1514c5f 100644 --- a/TODO.md +++ b/TODO.md @@ -7,6 +7,7 @@ - Deployment(PKGBUILD, bootstrap script?) - More complete sync(refresh packages on schedule with db, prefetch updates to pkgs we already have) - Build server/tool +- ~flag for loading non default config~ - ~Deployment(systemd, systemd.timer)~ - ~Basic testing for internal/cache~ - ~basic file server that fulfills pacman api~ diff --git a/main.go b/main.go index 2498ba7..6f4f634 100644 --- a/main.go +++ b/main.go @@ -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) }