diff options
| author | bndw <ben@bdw.to> | 2026-01-23 20:54:46 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-01-23 20:54:46 -0800 |
| commit | 98b9af372025595e8a4255538e2836e019311474 (patch) | |
| tree | 0a26fa5a8a19ea8565da6d63e1f19c21fc170d12 /cmd/deploy/list.go | |
| parent | 7fcb9dfa87310e91b527829ece9989decb6fda64 (diff) | |
Add deploy command and fix static site naming
Static sites now default to using the domain as the name instead of
the source directory basename, preventing conflicts when multiple
sites use the same directory name (e.g., dist).
Also fixes .gitignore to not exclude cmd/deploy/ directory.
Diffstat (limited to 'cmd/deploy/list.go')
| -rw-r--r-- | cmd/deploy/list.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/cmd/deploy/list.go b/cmd/deploy/list.go new file mode 100644 index 0000000..b74cf35 --- /dev/null +++ b/cmd/deploy/list.go | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | package main | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "flag" | ||
| 5 | "fmt" | ||
| 6 | "os" | ||
| 7 | "text/tabwriter" | ||
| 8 | |||
| 9 | "github.com/bdw/deploy/internal/config" | ||
| 10 | "github.com/bdw/deploy/internal/state" | ||
| 11 | ) | ||
| 12 | |||
| 13 | func runList(args []string) { | ||
| 14 | fs := flag.NewFlagSet("list", flag.ExitOnError) | ||
| 15 | host := fs.String("host", "", "VPS host (SSH config alias or user@host)") | ||
| 16 | fs.Parse(args) | ||
| 17 | |||
| 18 | // Get host from flag or config | ||
| 19 | if *host == "" { | ||
| 20 | cfg, err := config.Load() | ||
| 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 | |||
| 28 | if *host == "" { | ||
| 29 | fmt.Fprintf(os.Stderr, "Error: --host is required\n") | ||
| 30 | fs.Usage() | ||
| 31 | os.Exit(1) | ||
| 32 | } | ||
| 33 | |||
| 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) | ||
| 42 | if len(apps) == 0 { | ||
| 43 | fmt.Printf("No deployments found for %s\n", *host) | ||
| 44 | return | ||
| 45 | } | ||
| 46 | |||
| 47 | // Print table | ||
| 48 | w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0) | ||
| 49 | fmt.Fprintln(w, "NAME\tTYPE\tDOMAIN\tPORT") | ||
| 50 | for name, app := range apps { | ||
| 51 | port := "" | ||
| 52 | if app.Type == "app" { | ||
| 53 | port = fmt.Sprintf(":%d", app.Port) | ||
| 54 | } | ||
| 55 | fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", name, app.Type, app.Domain, port) | ||
| 56 | } | ||
| 57 | w.Flush() | ||
| 58 | } | ||
