From b5d97f633c960a826577fd80cb1d29e392dce34b Mon Sep 17 00:00:00 2001 From: bndw Date: Fri, 23 Jan 2026 21:10:04 -0800 Subject: Move default host from config file to state.json Instead of a separate ~/.config/deploy/config file, the default host is now stored as default_host in state.json. This simplifies the config and keeps all state in one place. The init command now automatically sets the default host if none is configured. --- internal/config/config.go | 65 ----------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 internal/config/config.go (limited to 'internal/config/config.go') diff --git a/internal/config/config.go b/internal/config/config.go deleted file mode 100644 index 8651aa8..0000000 --- a/internal/config/config.go +++ /dev/null @@ -1,65 +0,0 @@ -package config - -import ( - "bufio" - "os" - "path/filepath" - "strings" -) - -// Config represents the user's configuration -type Config struct { - Host string -} - -// Load reads config from ~/.config/deploy/config -func Load() (*Config, error) { - path := configPath() - - // If file doesn't exist, return empty config - if _, err := os.Stat(path); os.IsNotExist(err) { - return &Config{}, nil - } - - file, err := os.Open(path) - if err != nil { - return nil, err - } - defer file.Close() - - cfg := &Config{} - scanner := bufio.NewScanner(file) - for scanner.Scan() { - line := strings.TrimSpace(scanner.Text()) - if line == "" || strings.HasPrefix(line, "#") { - continue - } - - parts := strings.SplitN(line, ":", 2) - if len(parts) != 2 { - continue - } - - key := strings.TrimSpace(parts[0]) - value := strings.TrimSpace(parts[1]) - - switch key { - case "host": - cfg.Host = value - } - } - - if err := scanner.Err(); err != nil { - return nil, err - } - - return cfg, nil -} - -func configPath() string { - home, err := os.UserHomeDir() - if err != nil { - return ".deploy-config" - } - return filepath.Join(home, ".config", "deploy", "config") -} -- cgit v1.2.3