summaryrefslogtreecommitdiffstats
path: root/cmd/deploy/env.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/env.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/env.go')
-rw-r--r--cmd/deploy/env.go24
1 files changed, 9 insertions, 15 deletions
diff --git a/cmd/deploy/env.go b/cmd/deploy/env.go
index 135fb77..a43cd6a 100644
--- a/cmd/deploy/env.go
+++ b/cmd/deploy/env.go
@@ -6,7 +6,6 @@ import (
6 "os" 6 "os"
7 "strings" 7 "strings"
8 8
9 "github.com/bdw/deploy/internal/config"
10 "github.com/bdw/deploy/internal/ssh" 9 "github.com/bdw/deploy/internal/ssh"
11 "github.com/bdw/deploy/internal/state" 10 "github.com/bdw/deploy/internal/state"
12) 11)
@@ -29,14 +28,16 @@ func runEnv(args []string) {
29 28
30 name := fs.Args()[0] 29 name := fs.Args()[0]
31 30
32 // Get host from flag or config 31 // Load state
32 st, err := state.Load()
33 if err != nil {
34 fmt.Fprintf(os.Stderr, "Error loading state: %v\n", err)
35 os.Exit(1)
36 }
37
38 // Get host from flag or state default
33 if *host == "" { 39 if *host == "" {
34 cfg, err := config.Load() 40 *host = st.GetDefaultHost()
35 if err != nil {
36 fmt.Fprintf(os.Stderr, "Error loading config: %v\n", err)
37 os.Exit(1)
38 }
39 *host = cfg.Host
40 } 41 }
41 42
42 if *host == "" { 43 if *host == "" {
@@ -45,13 +46,6 @@ func runEnv(args []string) {
45 os.Exit(1) 46 os.Exit(1)
46 } 47 }
47 48
48 // Load state
49 st, err := state.Load()
50 if err != nil {
51 fmt.Fprintf(os.Stderr, "Error loading state: %v\n", err)
52 os.Exit(1)
53 }
54
55 // Get app info 49 // Get app info
56 app, err := st.GetApp(*host, name) 50 app, err := st.GetApp(*host, name)
57 if err != nil { 51 if err != nil {