local-search / src
Purpose
Application code for the CLI, including argument parsing, command dispatch, typed errors, browser control, and output rendering.
Mental model & key files
src/bin/lsearch.rsparses Clap arguments and turns typed errors into stable stderr JSON.lib.rsexposes the asyncrunentry point.cli.rsis declarative command/argument structure.commands/mod.rsis orchestration: attach browser, execute command, print result.error.rskeeps operator-facing messages and machine-readable error codes in one place.
Patterns to follow / invariants
- Keep command handlers thin enough to read from top to bottom.
- Prefer typed
Errorvariants over ad hoc strings. - Any command that may expose browser credentials should redact by default or require an explicit opt-in flag.
- Do not put CDP JSON protocol plumbing in command handlers when it belongs in
src/browser/.
Common tasks → first action
- New command: add Clap args, add command branch, update README, add CLI test.
- Managed browser cleanup: keep
cleanupdry-run by default, kill exact managed listener PIDs only, and never delete profile cookies/data. - New output mode: update
output.rsonly if the envelope contract changes. - New error: add variant in
error.rsand stablecode()mapping.
Gotchas
runowns the parsedCli; avoid async closures borrowing&mut CdpClientacross helper boundaries unless lifetimes are explicit.read --format text|markdownandhtmlwithout a path intentionally write raw body content instead of JSON.