CLI refactor

This commit is contained in:
2025-12-29 05:29:53 +02:00
parent d54b0eaddf
commit 16aaf1919d
9 changed files with 1111 additions and 585 deletions

View File

@@ -10,6 +10,9 @@ import (
// CLIConfig holds the CLI configuration
type CLIConfig struct {
ServerURL string
AuthKey string
Username string
Password string
}
// LoadCLIConfig loads configuration with priority: config file → ENV → flag
@@ -18,6 +21,9 @@ func LoadCLIConfig(configFile string, serverFlag string) (*CLIConfig, error) {
// Set defaults
v.SetDefault("server_url", "http://localhost:8080")
v.SetDefault("auth_key", "")
v.SetDefault("username", "")
v.SetDefault("password", "")
// 1. Load from config file (lowest priority)
if configFile != "" {
@@ -50,6 +56,9 @@ func LoadCLIConfig(configFile string, serverFlag string) (*CLIConfig, error) {
cfg := &CLIConfig{
ServerURL: v.GetString("server_url"),
AuthKey: v.GetString("auth_key"),
Username: v.GetString("username"),
Password: v.GetString("password"),
}
return cfg, nil