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
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>,
},
/// 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>,
},
/// 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,
},
/// Login to external services (runs all if no subcommand given)
Login {
#[command(subcommand)]
command: Option<LoginCommand>,
},
}
#[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
Add {
/// Server name (used as identifier in fleet.toml)
name: String,
/// Server IP address
#[arg(long)]
ip: String,
/// Override hostname (default: {name}.{domain})
#[arg(long)]
host: Option<String>,
/// Deploy user (created by Ansible, used for future SSH)
#[arg(long, default_value = "deploy")]
user: String,
/// SSH user for initial Ansible connection
#[arg(long, default_value = "root")]
ssh_user: 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 AppCommand {
/// Add a new app to fleet.toml
Add {
/// App name (used as identifier in fleet.toml)
name: String,
/// Docker image (e.g., ghcr.io/org/app:latest)
#[arg(long)]
image: String,
/// Server(s) to deploy to (must exist in fleet.toml, repeatable)
#[arg(long, required = true, num_args = 1..)]
server: Vec<String>,
/// Container port (required if routing is used)
#[arg(long)]
port: Option<u16>,
/// Route hostname(s) for Caddy reverse proxy (repeatable)
#[arg(long)]
route: 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, default_value = "rolling")]
deploy_strategy: 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,
},
}