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.
This commit is contained in:
+41
@@ -598,6 +598,10 @@ impl App {
|
||||
// 5 (export, import).
|
||||
match effective_input.as_str() {
|
||||
"quit" | "q" => return vec![Action::Quit],
|
||||
"help" => {
|
||||
self.note_help();
|
||||
return Vec::new();
|
||||
}
|
||||
"rebuild" => return vec![Action::PrepareRebuild],
|
||||
"save" => {
|
||||
return self.handle_save_command(false);
|
||||
@@ -1024,6 +1028,43 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
/// Note a flat list of currently-supported app-level
|
||||
/// commands to the output panel.
|
||||
///
|
||||
/// This is the simple Iteration-4 stand-in for a richer
|
||||
/// help system (H3 in the requirements doc); it gives the
|
||||
/// user a quick "what can I type?" reference that's
|
||||
/// always accurate against the build they're running. As
|
||||
/// new commands land, append them here.
|
||||
fn note_help(&mut self) {
|
||||
self.note_system("Supported commands:");
|
||||
for line in [
|
||||
" quit / q — exit",
|
||||
" help — this list",
|
||||
" mode simple|advanced — switch input mode",
|
||||
" rebuild — rebuild .db from project.yaml + data/ (with confirmation)",
|
||||
" save — save current temp project under a name",
|
||||
" save as — copy current project to a new name/path",
|
||||
" new — close current, start a fresh temp project",
|
||||
" load — open the project picker",
|
||||
"DSL data commands (in simple mode):",
|
||||
" create table <T> with pk [<col>:<type>...]",
|
||||
" drop table <T>",
|
||||
" add column [to table] <T>: <col> (<type>)",
|
||||
" add 1:n relationship [as <name>] from <P>.<col> to <C>.<col>",
|
||||
" [on delete <action>] [on update <action>] [--create-fk]",
|
||||
" drop relationship <name>",
|
||||
" insert into <T> [(cols)] [values] (vals)",
|
||||
" update <T> set <c>=<v>... where <c>=<v> | --all-rows",
|
||||
" delete from <T> where <c>=<v> | --all-rows",
|
||||
" show table <T>",
|
||||
" show data <T>",
|
||||
"Types: text, int, real, decimal, bool, date, datetime, blob, serial, shortid",
|
||||
] {
|
||||
self.note_system(line);
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_mode_command(&mut self, raw: &str) {
|
||||
let arg = raw.strip_prefix("mode").unwrap_or(raw).trim();
|
||||
match arg {
|
||||
|
||||
Reference in New Issue
Block a user