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
//! Command-line surface. With no subcommand, the TUI dashboard opens
//! (mirrors the ytunnel convention).
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(
name = "reeve",
version,
about = "Localhost web dev stack manager — web servers, per-vhost PHP, SSL, DNS.",
long_about = None
)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
/// Detect Homebrew, scaffold config/state, set up local CA + DNS.
Init,
/// Manage PHP versions and their FPM masters.
#[command(subcommand)]
Php(PhpCommands),
/// Manage web server instances.
#[command(subcommand)]
Server(ServerCommands),
/// Manage virtual hosts.
#[command(subcommand)]
Vhost(VhostCommands),
/// Manage background services (databases, redis, memcached, mailpit).
#[command(subcommand)]
Service(ServiceCommands),
/// Park a directory so every subfolder auto-serves as <folder>.<tld>.
#[command(subcommand)]
Park(ParkCommands),
/// Render generated configs and reconcile running services to state.
Apply,
/// Run every backend's native config test.
Validate,
/// Manage local SSL certificates.
#[command(subcommand)]
Ssl(SslCommands),
/// Manage local wildcard DNS for the dev TLD (default .test).
#[command(subcommand)]
Dns(DnsCommands),
/// View a managed service's log. Omit the target to list available logs.
Logs {
/// Target: server-<name>, php-<ver>, dnsmasq (or a bare server name).
target: Option<String>,
/// Number of trailing lines to show.
#[arg(long, short = 'n', default_value_t = 50)]
lines: usize,
/// Stream new lines as they arrive (like `tail -f`).
#[arg(long, short)]
follow: bool,
},
/// Diagnose the stack: Homebrew, servers, FPM, DNS, certs, ports.
Doctor,
/// Self-update reeve to the latest GitHub release.
Update {
/// Only report whether an update is available; don't install.
#[arg(long)]
check: bool,
},
/// (hidden) Render one TUI frame to text — for testing without a terminal.
#[command(hide = true)]
TuiSnapshot {
#[arg(long, default_value_t = 102)]
width: u16,
#[arg(long, default_value_t = 26)]
height: u16,
/// Open a modal for the snapshot: "wizard" (new vhost) or "server" (edit).
#[arg(long, default_value = "")]
modal: String,
},
}
#[derive(Subcommand, Debug)]
pub enum DnsCommands {
/// Install dnsmasq, resolve *.<tld> to 127.0.0.1, and wire up the resolver.
Setup,
/// Show DNS service + resolver status.
Status,
}
#[derive(Subcommand, Debug)]
pub enum PhpCommands {
/// Install a PHP version (e.g. `8.3`) and stand up its FPM master.
Install { version: String },
/// List installed PHP versions and FPM status.
List,
/// Set the default PHP version for new vhosts.
Use { version: String },
/// Switch the CLI `php` (via the ~/.reeve/bin shim). Omit the version to
/// show the current one.
Cli { version: Option<String> },
/// Manage PHP extensions for a version.
#[command(subcommand)]
Ext(ExtCommands),
/// Show effective php.ini / OPcache / FPM settings for a version.
Settings { version: String },
/// Set a php.ini / OPcache / FPM setting (see `php settings <ver>` for keys).
Set {
version: String,
key: String,
value: String,
},
/// Toggle Xdebug for a version: off | debug | profile.
Xdebug { version: String, mode: String },
}
#[derive(Subcommand, Debug)]
pub enum ExtCommands {
/// Enable/install an extension for a PHP version.
Add { version: String, name: String },
/// Disable an extension for a PHP version.
Remove { version: String, name: String },
/// List extensions for a PHP version.
List { version: String },
}
#[derive(Subcommand, Debug)]
pub enum ServerCommands {
/// Add a server instance.
Add {
/// Backend: caddy|apache|nginx|ols
backend: String,
/// Instance name (defaults to the backend name).
#[arg(long)]
name: Option<String>,
#[arg(long, default_value_t = 80)]
http: u16,
#[arg(long, default_value_t = 443)]
https: u16,
/// Serve a catch-all default site (sites root) on the HTTP port.
#[arg(long)]
default_site: bool,
/// Docroot for the default site. Defaults to the global sites root.
#[arg(long)]
root: Option<String>,
/// Framework preset for the default site: generic|laravel|wordpress|symfony|grav|drupal.
#[arg(long, default_value = "generic")]
preset: String,
},
/// Start a server.
Start { name: String },
/// Stop a server.
Stop { name: String },
/// Restart a server (picks up config changes).
Restart { name: String },
/// List servers and their status.
List,
/// Remove a server.
Remove { name: String },
}
#[derive(Subcommand, Debug)]
pub enum VhostCommands {
/// Add a vhost.
Add {
/// Hostname, e.g. grav.test
server_name: String,
#[arg(long)]
root: String,
/// PHP version (not needed for a `--proxy` vhost).
#[arg(long, default_value = "")]
php: String,
#[arg(long)]
server: String,
#[arg(long)]
ssl: bool,
/// Framework preset: generic|laravel|wordpress|symfony|grav|drupal.
#[arg(long, default_value = "generic")]
preset: String,
/// Make this a reverse proxy to an upstream URL (e.g. http://localhost:5173).
/// Mutually exclusive with PHP serving.
#[arg(long)]
proxy: Option<String>,
},
/// List vhosts.
List,
/// Remove a vhost.
Remove { server_name: String },
}
#[derive(Subcommand, Debug)]
pub enum ParkCommands {
/// Park a directory: subfolders auto-serve as <folder>.<tld>.
Add {
/// Directory to park (e.g. ~/Sites).
dir: String,
#[arg(long)]
server: String,
#[arg(long)]
php: String,
/// TLD for parked hosts (defaults to your first configured TLD).
#[arg(long)]
tld: Option<String>,
#[arg(long)]
ssl: bool,
},
/// Stop parking a directory.
Remove { dir: String },
/// List parked directories and the sites they currently expand to.
List,
}
#[derive(Subcommand, Debug)]
pub enum ServiceCommands {
/// Add a service (mysql|mariadb|postgres|redis|memcached|mailpit) to state.
Add { kind: String },
/// Install if needed, then start a service.
Start { kind: String },
/// Stop a service.
Stop { kind: String },
/// Restart a service.
Restart { kind: String },
/// List services and their status.
List,
/// Remove a service from state (leaves the brew formula installed).
Remove { kind: String },
}
#[derive(Subcommand, Debug)]
pub enum SslCommands {
/// Mint a certificate for a hostname from the shared local CA.
Mint { server_name: String },
/// Install the mkcert local CA into the system trust store (may prompt for
/// admin authorization). Run once so browsers trust local certs.
Trust,
/// Remove the mkcert local CA from the trust store (browsers stop trusting
/// local certs). The CA files stay on disk for a later `trust`.
Untrust,
/// Show whether the local CA is generated and trusted, and where it lives.
Status,
/// Print the local CA root certificate path.
Ca,
}