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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
mod cli;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(
name = "ryra",
version,
about = "Self-hosted service manager using rootless Podman quadlets"
)]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
/// Search available services in a registry
Search {
/// Filter by name or description
query: Option<String>,
/// Search a specific custom registry
#[arg(long)]
registry: Option<String>,
},
/// Add and start a service
Add {
/// Service(s): a registry name ("forgejo" / "acme/forgejo"), a local
/// project path ("." / "./path"), or omit to use ./service.toml here.
#[arg(num_args = 0..)]
services: Vec<String>,
/// Public URL for this service (e.g., https://docs.example.com)
#[arg(long)]
url: Option<String>,
/// Wire this service to OIDC SSO via Authelia. Auto-installs Authelia
/// at https://authelia.internal:<port> if it isn't already configured.
/// Only works for services that declare native OIDC support — see the
/// SUPPORTS column in `ryra search`.
#[arg(long)]
auth: bool,
/// Configure SMTP non-interactively. Currently the only choice is
/// "inbucket", which auto-installs the inbucket SMTP test server and
/// points this install (and any service added in the same batch)
/// at it. Skipped if SMTP is already configured.
#[arg(long, value_enum)]
smtp: Option<cli::add::SmtpProvider>,
/// Enable a named `[[env_group]]` bundle on the service (repeatable).
/// Required members of enabled groups are read from the process env
/// in non-interactive mode, or prompted for interactively.
#[arg(long = "enable", value_name = "GROUP")]
enable: Vec<String>,
/// Expose this service on your tailnet at
/// `https://<service>.<tailnet>.ts.net` via Tailscale Services.
/// Defines the service through the Tailscale admin API and runs
/// `tailscale serve --service=svc:<name>` from the host (sudo
/// required) — no sidecar containers, no port pool. Requires the
/// `tailscale` CLI installed and a logged-in tailnet (configure
/// the API token with TAILSCALE_API_KEY or interactively).
/// Mutually exclusive with --url.
#[arg(long, conflicts_with = "url")]
tailscale: bool,
/// Include this install in encrypted backups managed by
/// `ryra backup run`. Only valid for services whose manifest
/// sets `backup = true` under [integrations]. The actual
/// backup repository (S3 endpoint, password) is configured
/// once with `ryra backup configure`.
#[arg(long)]
backup: bool,
/// Use Let's Encrypt for Caddy-managed routes. Pass `--acme you@example.com`
/// to register with that email for renewal notices, or `--acme` alone to
/// register anonymously. Without this flag, Caddy uses its internal CA
/// (self-signed). After first install, edit
/// `~/.local/share/services/caddy/config/tls.caddy` directly to switch to
/// wildcards, Cloudflare DNS-01, BYO certs, etc.
#[arg(long, value_name = "EMAIL", num_args = 0..=1, default_missing_value = "")]
acme: Option<String>,
/// Skip confirmation prompts (including untrusted registry warnings)
#[arg(long, short = 'y')]
yes: bool,
/// Show what would happen without making changes
#[arg(long)]
dry_run: bool,
},
/// Remove a service
Remove {
/// Service name(s) to remove
#[arg(
required_unless_present_any = ["all", "orphans"],
num_args = 1..,
conflicts_with_all = ["all", "orphans"]
)]
services: Vec<String>,
/// Remove every installed service (use `ryra reset` to also wipe ryra's
/// config + CA)
#[arg(long, short = 'a', conflicts_with = "orphans")]
all: bool,
/// Purge every orphan service's data (leftover from prior `ryra remove`).
/// Never touches installed services.
#[arg(long)]
orphans: bool,
/// Skip confirmation prompt
#[arg(long, short = 'y')]
yes: bool,
/// Show what would happen without making changes
#[arg(long)]
dry_run: bool,
/// Destructive: also delete data subdirs and podman named volumes.
/// Without this flag, data is preserved and `ryra list` will show
/// the service as orphan afterwards. Also works on orphans to
/// clean up their leftover data.
#[arg(long)]
purge: bool,
},
/// List installed services
List {
/// Also show orphan services (removed but data still on disk)
#[arg(long, short = 'a')]
all: bool,
/// Long listing — include size + volume breakdown. Takes longer
/// because each volume requires a podman subprocess to measure.
#[arg(long, short = 'l')]
long: bool,
},
/// Start an installed service (and its sidecars).
Start {
/// Service name. Omit and pass --all to start every installed service.
#[arg(required_unless_present = "all", conflicts_with = "all")]
service: Option<String>,
/// Start every installed service.
#[arg(long, short = 'a')]
all: bool,
/// Show what would happen without making changes.
#[arg(long)]
dry_run: bool,
},
/// Stop an installed service (and its sidecars). Data is untouched —
/// `ryra start` brings it back. Use `ryra remove` to uninstall.
Stop {
/// Service name. Omit and pass --all to stop every installed service.
#[arg(required_unless_present = "all", conflicts_with = "all")]
service: Option<String>,
/// Stop every installed service.
#[arg(long, short = 'a')]
all: bool,
/// Show what would happen without making changes.
#[arg(long)]
dry_run: bool,
},
/// Global overview: config path, SMTP / auth providers, service count.
Status,
/// Manage custom registries
Registry {
#[command(subcommand)]
action: RegistryAction,
},
/// Run tests for a service. Runs the full lifecycle on this host by
/// default; pass --vm to run in an isolated throwaway VM instead.
Test {
/// Test name filters. Pick tests with names, or pass --all to run
/// everything; bare `ryra test` just prints this help.
names: Vec<String>,
/// Run every test in the registry.
#[arg(long, short = 'a', conflicts_with = "names")]
all: bool,
/// Run the full add/assert/remove lifecycle in a fresh, throwaway
/// QEMU VM instead of on this host. Slower, needs KVM, but isolated.
#[arg(long)]
vm: bool,
/// Run assertions against an already-installed service on this host
/// (no add/remove). Requires --service. Non-mutating.
#[arg(long)]
live: bool,
/// Deprecated: the host is now the default target, so this is a
/// no-op kept for backward compatibility (CI, scripts). Use --vm
/// to opt into a VM instead.
#[arg(long, hide = true)]
no_vm: bool,
/// Service to test (live mode)
#[arg(long)]
service: Option<String>,
/// Run only a specific test by name (live mode)
#[arg(long)]
test: Option<String>,
/// Repo to load test definitions from (git URL or local path)
#[arg(long)]
repo: Option<String>,
/// Test a local project directory with test.toml (+ optional quadlet files)
#[arg(long)]
project: Option<std::path::PathBuf>,
/// Skip setup steps (add/wait) and only re-run shell/playwright steps
#[arg(long)]
retest: bool,
/// Keep VM alive after tests (or boot without tests for interactive use)
#[arg(long)]
keep_alive: bool,
/// Skip confirmation prompts
#[arg(long, short)]
yes: bool,
/// Show real-time output from VM commands
#[arg(long, short)]
verbose: bool,
/// Max concurrent VMs (default: 1)
#[arg(long)]
parallel: Option<usize>,
/// Subcommand (e.g. `list`). Omit to run tests.
#[command(subcommand)]
action: Option<TestAction>,
},
/// Tear down all services, containers, and config
Reset {
/// Skip confirmation prompt
#[arg(long, short = 'y')]
yes: bool,
/// Show what would happen without making changes
#[arg(long)]
dry_run: bool,
},
/// Diagnose environment + install state and report issues with fixes
Doctor,
/// Scaffold a ryra service.toml + test.toml in the current project.
///
/// Additive (like `git init`): detects the project type (Cargo.toml / Bun
/// package.json) to infer the run/build commands, prompts for name +
/// description + port (defaults pre-filled), and writes the two files. Never
/// touches your source. Then `ryra add` runs it.
Init {
/// Service name (default: current directory name)
#[arg(long)]
name: Option<String>,
/// HTTP port the service listens on (skips the prompt)
#[arg(long)]
port: Option<u16>,
/// Accept all defaults without prompting
#[arg(short, long)]
yes: bool,
},
/// Preview what `ryra upgrade` would change. Read-only.
Diff {
/// Service name(s). Omit to diff every installed service.
services: Vec<String>,
},
/// Re-render an installed service against the current registry.
///
/// Backs up displaced files to ~/.local/state/ryra/backups/<UTC-ts>/<service>/
/// (last 5 snapshots kept) and restarts the unit. Refuses to clobber
/// hand-edited files unless --force.
Upgrade {
/// Service name(s). Omit to upgrade every installed service.
services: Vec<String>,
/// Skip confirmation prompt
#[arg(long, short = 'y')]
yes: bool,
/// Overwrite hand-edited files. Backups still go to
/// ~/.local/state/ryra/backups/<timestamp>/<service>/ first.
#[arg(long)]
force: bool,
/// Show what would happen without making changes
#[arg(long)]
dry_run: bool,
},
/// Restore an installed service from an upgrade backup.
Revert {
/// Service name(s) to revert. Required unless --list is set.
services: Vec<String>,
/// Specific snapshot timestamp (e.g. 2026-05-05T13-33-50Z). Omit
/// to use the most recent. Only valid for a single service.
#[arg(long)]
at: Option<String>,
/// Show available backup snapshots and exit. Combine with service
/// names to filter, or run alone to list every service's backups.
#[arg(long)]
list: bool,
/// Skip confirmation prompt
#[arg(long, short = 'y')]
yes: bool,
/// Show what would happen without making changes
#[arg(long)]
dry_run: bool,
},
/// Encrypted backups to an S3-compatible store (MinIO, AWS, R2, B2,
/// Wasabi) via restic.
Backup {
#[command(subcommand)]
action: cli::backup::BackupAction,
},
/// Reconfigure an installed service in place.
Configure {
/// Service name to reconfigure.
service: String,
/// Set or change the public URL.
#[arg(long, conflicts_with_all = ["no_url", "tailscale"])]
url: Option<String>,
/// Remove the public URL (drops the Caddy route, switches to loopback).
#[arg(long = "no-url", conflicts_with_all = ["url", "tailscale"])]
no_url: bool,
/// Switch this service to Tailscale Service exposure.
#[arg(long, conflicts_with_all = ["url", "no_url"])]
tailscale: bool,
/// Wire this service to the global SMTP relay.
#[arg(long, conflicts_with = "no_smtp")]
smtp: bool,
/// Stop wiring this service to the global SMTP relay.
#[arg(long = "no-smtp", conflicts_with = "smtp")]
no_smtp: bool,
/// Include this service in encrypted backups.
#[arg(long, conflicts_with = "no_backup")]
backup: bool,
/// Stop including this service in encrypted backups.
#[arg(long = "no-backup", conflicts_with = "backup")]
no_backup: bool,
/// Register an OIDC client with the auth provider and enable SSO.
/// Requires a `--url` if the service wasn't already URL-exposed.
#[arg(long, conflicts_with = "no_auth")]
auth: bool,
/// Unregister the OIDC client and disable SSO. Destructive.
#[arg(long = "no-auth", conflicts_with = "auth")]
no_auth: bool,
/// Enable a named env_group bundle (repeatable).
#[arg(long = "enable", value_name = "GROUP")]
enable: Vec<String>,
/// Disable a named env_group bundle (repeatable). Destructive —
/// drops the group's env vars from `.env`.
#[arg(long = "disable", value_name = "GROUP")]
disable: Vec<String>,
/// Override an individual env var (repeatable). Format: KEY=VALUE.
#[arg(long = "set", value_name = "KEY=VALUE")]
set: Vec<String>,
/// Skip confirmation prompts. Destructive changes still require
/// typed confirmation in an interactive session unless `--yes`
/// is combined with destructive flags (then they're auto-confirmed).
#[arg(long, short = 'y')]
yes: bool,
/// Show what would happen without making changes.
#[arg(long)]
dry_run: bool,
},
}
#[derive(Subcommand)]
enum TestAction {
/// Search available tests from the registry
Search {
/// Test name filters
names: Vec<String>,
/// Show full step details
#[arg(long, short)]
verbose: bool,
},
/// Show local test sandbox state: installed services and last run results
List,
/// Remove stored results for one or more tests (report, log, playwright,
/// per-test sandbox). Does not touch services or the ledger.
Remove {
/// Test names to remove
names: Vec<String>,
},
/// Tear down the test sandbox: purge leftover test services and delete
/// the sandbox dir (service data, preferences, ledger, run results).
/// `ryra reset` for the test footprint; real services are untouched.
Reset {
/// Skip confirmation prompt
#[arg(long, short = 'y')]
yes: bool,
},
}
#[derive(Subcommand)]
enum RegistryAction {
/// Add a custom registry
Add {
/// Registry name (used as namespace, e.g., "acme")
name: String,
/// Git URL of the registry repo
url: String,
},
/// Remove a custom registry
Remove {
/// Registry name
name: String,
},
/// Update (git pull) custom registries
Update {
/// Specific registry to update (default: all)
name: Option<String>,
},
/// List custom registries
List,
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
match cli.command {
Command::Add {
services,
url,
auth,
smtp,
enable,
tailscale,
backup,
acme,
yes,
dry_run,
} => {
// Map clap's raw flags to typed values at the CLI boundary so
// every interior call site pattern-matches exhaustive enums
// instead of poking at `Option<String>`s with empty-string
// sentinels:
// --acme absent → None (planner falls back to Internal)
// `--acme` → Some(Anonymous)
// `--acme me@foo.bar` → Some(WithEmail(...))
// --url / --tailscale fold into one ExposureRequest (clap's
// conflicts_with already rejects passing both).
let acme_mode: Option<ryra_core::caddy::AcmeMode> = acme.as_deref().map(|s| {
if s.is_empty() {
ryra_core::caddy::AcmeMode::Anonymous
} else {
ryra_core::caddy::AcmeMode::WithEmail(s.to_string())
}
});
let exposure = match url {
Some(u) => cli::add::ExposureRequest::Url(u),
None if tailscale => cli::add::ExposureRequest::Tailscale,
None => cli::add::ExposureRequest::Auto,
};
cli::add::run(cli::add::AddRequest {
services,
exposure,
auth,
smtp,
enable,
backup,
acme: acme_mode,
dry_run,
yes,
})
.await?
}
Command::Remove {
ref services,
all,
orphans,
yes,
dry_run,
purge,
} => cli::remove::run(services, all, orphans, yes, dry_run, purge).await?,
Command::Reset { yes, dry_run } => cli::reset::run(yes, dry_run).await?,
Command::Doctor => cli::doctor::run()?,
Command::Init {
ref name,
port,
yes,
} => cli::init::run(name.as_deref(), port, yes)?,
Command::Diff { ref services } => cli::diff::run(services).await?,
Command::Upgrade {
ref services,
yes,
force,
dry_run,
} => cli::upgrade::run(services, yes, force, dry_run).await?,
Command::Revert {
ref services,
ref at,
list,
yes,
dry_run,
} => cli::revert::run(services, at.as_deref(), yes, dry_run, list).await?,
Command::Backup { action } => cli::backup::run(action).await?,
Command::Configure {
ref service,
ref url,
no_url,
tailscale,
smtp,
no_smtp,
backup,
no_backup,
auth,
no_auth,
ref enable,
ref disable,
ref set,
yes,
dry_run,
} => {
let flags = cli::configure::ConfigureFlags {
url: url.clone(),
no_url,
tailscale,
smtp,
no_smtp,
backup,
no_backup,
auth,
no_auth,
enable: enable.clone(),
disable: disable.clone(),
set: set.clone(),
yes,
dry_run,
};
cli::configure::run(service, flags).await?
}
Command::Start {
ref service,
all,
dry_run,
} => {
cli::lifecycle::run(
service.as_deref(),
all,
ryra_core::Lifecycle::Start,
dry_run,
)
.await?
}
Command::Stop {
ref service,
all,
dry_run,
} => {
cli::lifecycle::run(service.as_deref(), all, ryra_core::Lifecycle::Stop, dry_run)
.await?
}
Command::Status => cli::status::run().await?,
Command::List { all, long } => cli::list::run(all, long)?,
Command::Search {
ref query,
ref registry,
} => cli::search::run(query.as_deref(), registry.as_deref()).await?,
Command::Test {
ref names,
all,
vm,
live,
no_vm: _,
retest,
ref service,
ref test,
repo: _,
ref project,
keep_alive,
yes,
verbose,
parallel,
ref action,
} => {
// `ryra test list [-v] [names…]` is a subcommand; everything
// else is the normal run path.
let (effective_list, effective_verbose, effective_names): (bool, bool, &[String]) =
match action {
Some(TestAction::Search {
names: search_names,
verbose: search_verbose,
}) => (true, *search_verbose || verbose, search_names.as_slice()),
Some(TestAction::List) => {
cli::test::show_sandbox_state();
return Ok(());
}
Some(TestAction::Remove {
names: remove_names,
}) => {
cli::test::remove_tests(remove_names);
return Ok(());
}
Some(TestAction::Reset { yes: reset_yes }) => {
cli::test::reset_sandbox(*reset_yes || yes).await?;
return Ok(());
}
None => {
// Running everything must be asked for explicitly
// (--all), because the default mode installs and
// purges every service the registry declares on
// THIS host. Without --all, names, or another
// explicit target (--project, --live, --keep-alive),
// print help instead of running the world.
let has_target =
all || !names.is_empty() || project.is_some() || live || keep_alive;
if !has_target {
use clap::CommandFactory;
let mut sub = Cli::command()
.find_subcommand("test")
.cloned()
.unwrap_or_else(|| {
unreachable!("'test' is declared in the Command enum")
})
// Printed outside a parse, so clap hasn't
// propagated the parent bin name into the
// usage line; set it explicitly.
.bin_name("ryra test");
sub.print_help()?;
// Exit non-zero (clap's missing-required-arg code)
// so scripts that relied on bare `ryra test`
// running everything fail loudly instead of
// silently passing.
std::process::exit(2);
}
(false, verbose, names.as_slice())
}
};
cli::test::run(cli::test::TestRunParams {
service: service.as_deref(),
test_filter: test.as_deref(),
project: project.as_ref(),
vm,
live,
retest,
keep_alive,
yes,
verbose: effective_verbose,
list: effective_list,
parallel,
names: effective_names,
})
.await?
}
Command::Registry { action } => match action {
RegistryAction::Add { ref name, ref url } => cli::registry_cmd::add(name, url).await?,
RegistryAction::Remove { ref name } => cli::registry_cmd::remove(name)?,
RegistryAction::Update { ref name } => {
cli::registry_cmd::update(name.as_deref()).await?
}
RegistryAction::List => cli::registry_cmd::list()?,
},
}
Ok(())
}