diff options
| author | bndw <ben@bdw.to> | 2026-01-23 21:19:50 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-01-23 21:19:50 -0800 |
| commit | 1694ba1b8ad68e2d2ad21c1442c29b6f3f2c1632 (patch) | |
| tree | 9411bc6b4b273263e31b33aa37dead47cdec4be4 /cmd | |
| parent | b5d97f633c960a826577fd80cb1d29e392dce34b (diff) | |
Make deploy the default action and require --binary
- Remove "deploy" subcommand, deploy is now the default action
- Require --binary flag explicitly (no auto-discovery)
- Add "rm" as alias for "remove"
- Update help text
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/deploy/deploy.go | 25 | ||||
| -rw-r--r-- | cmd/deploy/main.go | 30 |
2 files changed, 20 insertions, 35 deletions
diff --git a/cmd/deploy/deploy.go b/cmd/deploy/deploy.go index ee7ee4a..31aabe5 100644 --- a/cmd/deploy/deploy.go +++ b/cmd/deploy/deploy.go | |||
| @@ -78,26 +78,15 @@ func runDeploy(args []string) { | |||
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | func deployApp(host, domain, name, binaryPath string, portOverride int, envVars []string, envFile, args string, files []string) { | 80 | func deployApp(host, domain, name, binaryPath string, portOverride int, envVars []string, envFile, args string, files []string) { |
| 81 | // Determine app name | 81 | // Require binary path |
| 82 | if name == "" { | 82 | if binaryPath == "" { |
| 83 | if binaryPath != "" { | 83 | fmt.Fprintf(os.Stderr, "Error: --binary is required\n") |
| 84 | name = filepath.Base(binaryPath) | 84 | os.Exit(1) |
| 85 | } else { | ||
| 86 | // Try to find a binary in current directory | ||
| 87 | cwd, _ := os.Getwd() | ||
| 88 | name = filepath.Base(cwd) | ||
| 89 | } | ||
| 90 | } | 85 | } |
| 91 | 86 | ||
| 92 | // Find binary if not specified | 87 | // Determine app name from binary if not specified |
| 93 | if binaryPath == "" { | 88 | if name == "" { |
| 94 | // Look for binary with same name as directory | 89 | name = filepath.Base(binaryPath) |
| 95 | if _, err := os.Stat(name); err == nil { | ||
| 96 | binaryPath = name | ||
| 97 | } else { | ||
| 98 | fmt.Fprintf(os.Stderr, "Error: --binary is required (could not find binary in current directory)\n") | ||
| 99 | os.Exit(1) | ||
| 100 | } | ||
| 101 | } | 90 | } |
| 102 | 91 | ||
| 103 | // Verify binary exists | 92 | // Verify binary exists |
diff --git a/cmd/deploy/main.go b/cmd/deploy/main.go index 1589af3..e86eff7 100644 --- a/cmd/deploy/main.go +++ b/cmd/deploy/main.go | |||
| @@ -16,11 +16,9 @@ func main() { | |||
| 16 | switch command { | 16 | switch command { |
| 17 | case "init": | 17 | case "init": |
| 18 | runInit(os.Args[2:]) | 18 | runInit(os.Args[2:]) |
| 19 | case "deploy": | ||
| 20 | runDeploy(os.Args[2:]) | ||
| 21 | case "list": | 19 | case "list": |
| 22 | runList(os.Args[2:]) | 20 | runList(os.Args[2:]) |
| 23 | case "remove": | 21 | case "rm", "remove": |
| 24 | runRemove(os.Args[2:]) | 22 | runRemove(os.Args[2:]) |
| 25 | case "logs": | 23 | case "logs": |
| 26 | runLogs(os.Args[2:]) | 24 | runLogs(os.Args[2:]) |
| @@ -35,9 +33,8 @@ func main() { | |||
| 35 | case "help", "--help", "-h": | 33 | case "help", "--help", "-h": |
| 36 | printUsage() | 34 | printUsage() |
| 37 | default: | 35 | default: |
| 38 | fmt.Fprintf(os.Stderr, "Unknown command: %s\n\n", command) | 36 | // Default action is deploy - pass all args including the first one |
| 39 | printUsage() | 37 | runDeploy(os.Args[1:]) |
| 40 | os.Exit(1) | ||
| 41 | } | 38 | } |
| 42 | } | 39 | } |
| 43 | 40 | ||
| @@ -45,13 +42,13 @@ func printUsage() { | |||
| 45 | usage := `deploy - Deploy Go apps and static sites to a VPS with automatic HTTPS | 42 | usage := `deploy - Deploy Go apps and static sites to a VPS with automatic HTTPS |
| 46 | 43 | ||
| 47 | USAGE: | 44 | USAGE: |
| 48 | deploy <command> [flags] | 45 | deploy [flags] Deploy an app or static site |
| 46 | deploy <command> [flags] Run a subcommand | ||
| 49 | 47 | ||
| 50 | COMMANDS: | 48 | COMMANDS: |
| 51 | init Initialize a fresh VPS (one-time setup) | 49 | init Initialize a fresh VPS (one-time setup) |
| 52 | deploy Deploy a Go app or static site | ||
| 53 | list List all deployed apps and sites | 50 | list List all deployed apps and sites |
| 54 | remove Remove a deployment | 51 | rm Remove a deployment |
| 55 | logs View logs for a deployment | 52 | logs View logs for a deployment |
| 56 | status Check status of a deployment | 53 | status Check status of a deployment |
| 57 | restart Restart a deployment | 54 | restart Restart a deployment |
| @@ -59,24 +56,23 @@ COMMANDS: | |||
| 59 | webui Launch web UI to manage deployments | 56 | webui Launch web UI to manage deployments |
| 60 | 57 | ||
| 61 | FLAGS: | 58 | FLAGS: |
| 62 | Run 'deploy <command> -h' for command-specific flags | 59 | Run 'deploy -h' or 'deploy <command> -h' for flags |
| 63 | 60 | ||
| 64 | EXAMPLES: | 61 | EXAMPLES: |
| 65 | # Initialize VPS | 62 | # Initialize VPS (sets it as default host) |
| 66 | deploy init --host user@vps-ip | 63 | deploy init --host user@vps-ip |
| 67 | 64 | ||
| 68 | # Deploy Go app | 65 | # Deploy Go app |
| 69 | deploy deploy --host user@vps-ip --binary ./myapp --domain api.example.com | 66 | deploy --binary ./myapp --domain api.example.com |
| 70 | 67 | ||
| 71 | # Deploy static site | 68 | # Deploy static site |
| 72 | deploy deploy --host user@vps-ip --static --dir ./dist --domain example.com | 69 | deploy --static --dir ./dist --domain example.com |
| 73 | 70 | ||
| 74 | # List deployments | 71 | # List deployments |
| 75 | deploy list --host user@vps-ip | 72 | deploy list |
| 76 | 73 | ||
| 77 | CONFIG FILE: | 74 | # View logs |
| 78 | Create ~/.config/deploy/config to set default host: | 75 | deploy logs myapp |
| 79 | host: user@your-vps-ip | ||
| 80 | ` | 76 | ` |
| 81 | fmt.Fprint(os.Stderr, usage) | 77 | fmt.Fprint(os.Stderr, usage) |
| 82 | } | 78 | } |
