Files
rdbms-playground/src/main.rs
T
claude@clouddev1 b7addd6161 Cleanup pass: --help, in-app help, post-rebuild message, unmodified-temp cleanup
Four post-Iteration-4 polish items surfaced by manual testing.

1. `--help` / `-h` CLI flag prints a usage banner (options +
   app-level commands + DSL grammar reference) and exits. Parse
   errors also print the banner to stderr.

2. `help` app-level command notes the same list of supported
   commands to the output panel -- a simple stand-in for the
   richer H3 help system, kept in sync with what's actually
   wired up.

3. The silent rebuild that runs when playground.db is missing
   now surfaces a system message in the output panel ("[ok]
   rebuild -- N tables, M rows reconstructed; ...") via a new
   initial_events plumbing. The user no longer wonders whether
   the .db was magically restored or whether anything happened
   on launch.

4. Unmodified empty temp projects (kind=Temp, project.yaml has
   tables: [] and relationships: []) are now auto-deleted when
   the user switches away (load / new / save as) or quits. This
   addresses the "launch app, load existing project, quit"
   pattern that was leaving an empty temp directory behind
   every time. Modified temps (with any user-created tables or
   relationships) are never auto-deleted; corrupted projects
   are also never auto-deleted (defensive default-to-false on
   yaml read/parse errors).

Tests: 338 passing (272 lib + 9 + 5 + 6 + 20 + 9 + 17),
0 failing, 0 skipped. Clippy clean.
2026-05-08 06:43:49 +00:00

43 lines
1.1 KiB
Rust

use std::process::ExitCode;
use rdbms_playground::cli::{Args, HELP_TEXT};
use rdbms_playground::{logging, runtime};
fn main() -> ExitCode {
let args = match Args::from_env() {
Ok(args) => args,
Err(e) => {
eprintln!("rdbms-playground: {e}");
eprintln!("\n{HELP_TEXT}");
return ExitCode::from(2);
}
};
if args.help {
print!("{HELP_TEXT}");
return ExitCode::SUCCESS;
}
if let Err(e) = logging::init(args.log_path.as_deref()) {
eprintln!("rdbms-playground: failed to initialise logging: {e:#}");
return ExitCode::FAILURE;
}
let tokio_rt = match tokio::runtime::Runtime::new() {
Ok(rt) => rt,
Err(e) => {
tracing::error!(error = %e, "failed to start tokio runtime");
return ExitCode::FAILURE;
}
};
match tokio_rt.block_on(runtime::run(args)) {
Ok(()) => ExitCode::SUCCESS,
Err(e) => {
tracing::error!(error = %e, "runtime exited with error");
eprintln!("rdbms-playground: {e:#}");
ExitCode::FAILURE
}
}
}