Add ability to override config file

This commit is contained in:
Andrew-71 2024-03-26 18:26:34 +03:00
parent 4a6eb28afd
commit f556ae0460
2 changed files with 12 additions and 2 deletions

View file

@ -4,8 +4,9 @@ List of things to add to this project
* Make scram configurable * Make scram configurable
* Use reflection in config loading * Use reflection in config loading
* Check export function for improvements * Check export function for improvements
* Improve viewing of data (textarea over raw API requests) * Improve viewing of days (textarea over raw API requests), add notes to frontend
* More slog.Debug and a debug flag? * More slog.Debug and a debug flag?
* Think about timezones * Think about timezones
* Consider more secure auth methods * Consider more secure auth methods
* *Go* dependency-less? <-- this is a terrible idea * *Go* dependency-less? <-- this is a terrible idea
* Better visual feedback from JS?

View file

@ -2,14 +2,23 @@ package main
import ( import (
"flag" "flag"
"log"
) )
func FlagInit() { func FlagInit() {
config := flag.String("config", "", "override config file")
username := flag.String("user", "", "override username") username := flag.String("user", "", "override username")
password := flag.String("pass", "", "override password") password := flag.String("pass", "", "override password")
port := flag.Int("port", 0, "override port") port := flag.Int("port", 0, "override port")
flag.Parse() flag.Parse()
if *config != "" {
ConfigFile = *config
err := Cfg.Reload()
if err != nil {
log.Fatal(err)
}
}
if *username != "" { if *username != "" {
Cfg.Username = *username Cfg.Username = *username
} }