refactor(command): update parsing to use registry-based system

Update the command parsing layer to use the new CmdRegistry:

- parse_line() now uses default_registry() and returns Vec<Box<dyn Cmd>>
- parse_line_with() accepts a registry parameter for custom registries
- Tokenization replaced direct Command construction with registry.parse()
- Updated tests to verify command names instead of struct fields
- Removed parse_command() and helper functions (require_args, parse_coords,
  etc.)

The parser now delegates command construction to the registry, which
allows commands to be defined and registered in one place.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M)
This commit is contained in:
Edward Langley
2026-04-04 10:56:35 -07:00
parent 909c20bcbd
commit 64ab352490
2 changed files with 34 additions and 267 deletions

View File

@ -1,16 +1,12 @@
//! Command layer — all model mutations go through this layer so they can be
//! replayed, scripted, and tested without the TUI.
//!
//! Each command is a JSON object: `{"op": "CommandName", ...args}`.
//! The headless CLI (--cmd / --script) routes through here, and the TUI
//! App also calls dispatch() for every user action that mutates state.
//! Commands are trait objects (`dyn Cmd`) that produce effects (`dyn Effect`).
//! The headless CLI (--cmd / --script) parses Forth-style text into effects
//! and applies them directly.
pub mod cmd;
pub mod dispatch;
pub mod keymap;
pub mod parse;
pub mod types;
pub use dispatch::dispatch;
pub use parse::parse_line;
pub use types::{Command, CommandResult};