summaryrefslogtreecommitdiffstats
path: root/cmd/deploy/list.go
diff options
context:
space:
mode:
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)