1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(name = "flow", about = "Deploy and manage the Flow fleet")]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
/// Path to fleet.toml (default: fleet.toml in current directory)
#[arg(long, global = true, default_value = "fleet.toml")]
pub config: String,
}
#[derive(Subcommand)]
pub enum Command {
/// Deploy an app (or all apps if no name given)
Deploy {
/// App name to deploy (deploys all if omitted)
app: Option<String>,
/// Force recreate containers instead of rolling deploy
#[arg(long)]
force: bool,
},
/// Verify fleet.toml matches reality on servers
Check {
/// Filter by server name
#[arg(long)]
server: Option<String>,
/// Re-run Ansible hardening playbook
#[arg(long)]
with_hardening: bool,
},
/// Show fleet-wide status and container info
Status {
/// Filter by server name
#[arg(long)]
server: Option<String>,
/// Keep refreshing every second
#[arg(short = 'f', long)]
follow: bool,
/// Show image column
#[arg(long)]
image: bool,
/// Show ports column
#[arg(long)]
ports: bool,
/// Show size column
#[arg(long)]
size: bool,
},
/// Tail logs from an app
Logs {
/// App name
app: String,
/// Follow log output
#[arg(short, long)]
follow: bool,
/// Server to tail logs from (defaults to first server)
#[arg(long)]
server: Option<String>,
},
/// Stop an app's containers (keeps config, files, and DNS intact)
Stop {
/// App name to stop
app: String,
/// Stop only on this server (defaults to all assigned servers)
#[arg(long)]
server: Option<String>,
},
/// Restart an app's containers without redeploying
Restart {
/// App name to restart
app: String,
/// Restart only on this server (defaults to all assigned servers)
#[arg(long)]
server: Option<String>,
},
/// Remove an app: stop containers, clean up files, DNS, and fleet.toml
Remove {
/// App name to remove
app: String,
/// Skip confirmation prompt
#[arg(long)]
yes: bool,
},
/// Initialize a new fleet.toml in the current directory
Init,
/// Manage servers
Server {
#[command(subcommand)]
command: ServerCommand,
},
/// Manage apps in fleet.toml
App {
#[command(subcommand)]
command: AppCommand,
},
/// Manage GitHub Actions self-hosted runners
Runner {
#[command(subcommand)]
command: RunnerCommand,
},
/// Login to external services (runs all if no subcommand given)
Login {
#[command(subcommand)]
command: Option<LoginCommand>,
},
/// Manage app databases
Db {
#[command(subcommand)]
command: DbCommand,
},
/// Manage environment variables in fleet.env.toml
Env {
/// [app] [key=value...] — list/set env vars
args: Vec<String>,
},
/// Update flow CLI to the latest version
Update,
}
#[derive(Subcommand)]
pub enum LoginCommand {
/// Set Cloudflare API token
Cf,
/// Set GitHub Container Registry token
Gh,
}
#[derive(Subcommand)]
pub enum ServerCommand {
/// Add a new server and run Ansible to bootstrap it (interactive wizard if no args given)
Add {
/// Server name (used as identifier in fleet.toml)
name: Option<String>,
/// Server IP address
#[arg(long)]
ip: Option<String>,
/// Override hostname (default: {name}.{domain})
#[arg(long)]
host: Option<String>,
/// Deploy user (created by Ansible, used for future SSH)
#[arg(long)]
user: Option<String>,
/// SSH user for initial Ansible connection
#[arg(long)]
ssh_user: Option<String>,
/// Path to SSH public key for the deploy user
#[arg(long)]
ssh_key: Option<String>,
},
/// Remove a server from fleet.toml
Remove {
/// Server name to remove
name: String,
},
}
#[derive(Subcommand)]
pub enum DbCommand {
/// Open an interactive psql shell
Shell {
/// App name (defaults to first app with postgres)
app: Option<String>,
/// Server to connect to (defaults to first server)
#[arg(long)]
server: Option<String>,
},
/// Dump the database to a local file
Dump {
/// App name (defaults to first app with postgres)
app: Option<String>,
/// Output file path (default: {app}.sql.gz)
#[arg(short, long)]
output: Option<String>,
/// Server to dump from (defaults to first server)
#[arg(long)]
server: Option<String>,
},
/// Restore the database from a local SQL file
Restore {
/// App name (defaults to first app with postgres)
app: Option<String>,
/// Path to .sql or .sql.gz file
file: String,
/// Skip confirmation prompt
#[arg(long)]
yes: bool,
/// Server to restore to (defaults to first server)
#[arg(long)]
server: Option<String>,
},
/// List available backups on the server
List {
/// App name (defaults to first app with postgres)
app: Option<String>,
/// Server to list backups from (defaults to first server)
#[arg(long)]
server: Option<String>,
},
}
#[derive(Subcommand)]
pub enum RunnerCommand {
/// Add a self-hosted runner (interactive wizard if no args given)
Add {
/// Runner name (used as identifier in fleet.toml)
name: Option<String>,
/// Server to deploy to (must exist in fleet.toml)
#[arg(long)]
server: Option<String>,
/// Runner scope: org or repo
#[arg(long)]
scope: Option<String>,
/// Target org name or owner/repo
#[arg(long)]
target: Option<String>,
/// Runner label(s) (repeatable)
#[arg(long)]
label: Vec<String>,
/// Single-job ephemeral mode (default: true)
#[arg(long)]
ephemeral: bool,
},
/// Remove a runner from fleet.toml and clean up on server
Remove {
/// Runner name to remove
name: String,
/// Skip confirmation prompt
#[arg(long)]
yes: bool,
},
/// List runners and their status from GitHub API
List,
}
#[derive(Subcommand)]
pub enum AppCommand {
/// Add a new app to fleet.toml (interactive wizard if no args given)
Add {
/// App name (used as identifier in fleet.toml)
name: Option<String>,
/// Docker image (e.g., ghcr.io/org/app:latest)
#[arg(long)]
image: Option<String>,
/// Server(s) to deploy to (must exist in fleet.toml, repeatable)
#[arg(long)]
server: Vec<String>,
/// Container port (required if routing is used)
#[arg(long)]
port: Option<u16>,
/// Domain hostname(s) for Caddy reverse proxy (repeatable)
#[arg(long)]
domain: Vec<String>,
/// Health check path (e.g., /health)
#[arg(long)]
health_path: Option<String>,
/// Health check interval (e.g., 5s, 1m)
#[arg(long)]
health_interval: Option<String>,
/// Direct port mapping(s) in external:internal[/protocol] format (repeatable)
#[arg(long, value_name = "EXTERNAL:INTERNAL[/PROTOCOL]")]
port_map: Vec<String>,
/// Deploy strategy: rolling (default) or recreate
#[arg(long)]
deploy_strategy: Option<String>,
},
/// Add a sidecar service to an existing app
AddService {
/// App name (must exist in fleet.toml)
app: String,
/// Service name
name: String,
/// Docker image for the service
#[arg(long)]
image: String,
/// Volume mount(s) in name:path format (repeatable)
#[arg(long)]
volume: Vec<String>,
/// Healthcheck command
#[arg(long)]
healthcheck: Option<String>,
/// Service this depends on (must exist in same app)
#[arg(long)]
depends_on: Option<String>,
},
/// Remove a sidecar service from an app
RemoveService {
/// App name
app: String,
/// Service name to remove
name: String,
},
}