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
//! 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),
/// 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),
/// (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 },
/// Manage PHP extensions for a version.
#[command(subcommand)]
Ext(ExtCommands),
}
#[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,
},
/// 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,
#[arg(long)]
php: String,
#[arg(long)]
server: String,
#[arg(long)]
ssl: bool,
},
/// List vhosts.
List,
/// Remove a vhost.
Remove { server_name: 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,
/// Print the local CA root certificate path.
Ca,
}