summaryrefslogtreecommitdiffstats
path: root/cmd/deploy/list.go
diff options
context:
space:
mode:
authorbndw <ben@bdw.to>2026-01-23 21:10:04 -0800
committerbndw <ben@bdw.to>2026-01-23 21:10:04 -0800
commitb5d97f633c960a826577fd80cb1d29e392dce34b (patch)
tree312b934506f835bcc77c4dcbb9e38a27efbf1528 /cmd/deploy/list.go
parent98b9af372025595e8a4255538e2836e019311474 (diff)
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.
Diffstat (limited to 'cmd/deploy/list.go')
-rw-r--r--cmd/deploy/list.go24
1 files changed, 9 insertions, 15 deletions
diff --git a/cmd/deploy/list.go b/cmd/deploy/list.go
index b74cf35..ce1605b 100644
--- a/cmd/deploy/list.go
+++ b/cmd/deploy/list.go
@@ -6,7 +6,6 @@ import (
6 "os" 6 "os"
7 "text/tabwriter" 7 "text/tabwriter"
8 8
9 "github.com/bdw/deploy/internal/config"
10 "github.com/bdw/deploy/internal/state" 9 "github.com/bdw/deploy/internal/state"
11) 10)
12 11
@@ -15,14 +14,16 @@ func runList(args []string) {
15 host := fs.String("host", "", "VPS host (SSH config alias or user@host)") 14 host := fs.String("host", "", "VPS host (SSH config alias or user@host)")
16 fs.Parse(args) 15 fs.Parse(args)
17 16
18 // Get host from flag or config 17 // Load state
18 st, err := state.Load()
19 if err != nil {
20 fmt.Fprintf(os.Stderr, "Error loading state: %v\n", err)
21 os.Exit(1)
22 }
23
24 // Get host from flag or state default
19 if *host == "" { 25 if *host == "" {
20 cfg, err := config.Load() 26 *host = st.GetDefaultHost()
21 if err != nil {
22 fmt.Fprintf(os.Stderr, "Error loading config: %v\n", err)
23 os.Exit(1)
24 }
25 *host = cfg.Host
26 } 27 }
27 28
28 if *host == "" { 29 if *host == "" {
@@ -31,13 +32,6 @@ func runList(args []string) {
31 os.Exit(1) 32 os.Exit(1)
32 } 33 }
33 34
34 // Load state
35 st, err := state.Load()
36 if err != nil {
37 fmt.Fprintf(os.Stderr, "Error loading state: %v\n", err)
38 os.Exit(1)
39 }
40
41 apps := st.ListApps(*host) 35 apps := st.ListApps(*host)
42 if len(apps) == 0 { 36 if len(apps) == 0 {
43 fmt.Printf("No deployments found for %s\n", *host) 37 fmt.Printf("No deployments found for %s\n", *host)