crabidy/plan/cli.md

3.3 KiB

Plan: the CLI

Ordered, dependency-first tasks for architecture/cli.md, each mapped to the gate(s)/test(s) it satisfies.

Foundations

  • Add clap_complete + clap_mangen workspace deps; create the cbd-cli crate (clap defs default; client feature adds the gRPC executor).
  • cbd-cli: Role, RemoteArgs, Connection, the command enums, the three top-level Clis, generate_assets, print_completions, and a run_remote stub. Compiles with and without client.

Remote executor (cbd-cli client feature)

  • Implement run_remote: dispatch every LibraryCmd/QueueCmd/GlobalCmd to its RPC via the generated client; pretty-print listings and the queue; concise messages for mutations. Add the missing Stop call. (Gates: remote commands. Tests: a request-mapping unit test per group against a fake tonic server, or at least argument-parse tests for the clap tree.)
  • Map gRPC Status/transport errors to a short color-eyre/eyre report (no chain dump for "unreachable"). (Gate: remote errors.)

Config writers

  • Server: ServerSettings::store(config_dir) round-trips [auth] (preserve other roles, flat shape). (Gate: guard config write. Test: set one role, reload, other roles intact.)
  • Client: a Config writer (load/modify/save cbd-tui.toml/cbd.toml). (Gate: auth. Test: round-trip user/password/address.)

Server binary (crabidy-server)

  • Replace the Cli/HashPassword with cbd_cli::ServerCli. No subcommand → serve() (unchanged). (Gate: no-subcommand default.)
  • guard: hash (stdin fallback), print PHC, write config unless --no-config. Remove hash-password. (Gate: guard.)
  • scan: walk + write tomls; --capture/--move via a new CrabidyStore::ingest_file(path, move) -> StoreName (factor the local-source half of the D4 capture flow). (Gate: scan. Tests: toml written; capture dedups; move removes source; existing toml skipped.)
  • library/queue/globalcbd_cli::run_remote (enable cbd-cli client). completionsprint_completions.

Client binary (cbd-tui) and cbd

  • Replace ClapSerde parsing: parse cbd_cli::TuiCli; load the TOML config and apply remote/spectrum overrides; no subcommand → run(config). (Gate: parsing/defaults. Tests: flag overrides file; first-run writes file.)
  • auth writes the client config; library/queue/globalrun_remote; completions prints.
  • cbd: parse cbd_cli::CbdCli; no subcommand → server + TUI (unchanged); subcommands dispatch to the server (guard/scan), client (auth), or remote (library/queue/global) paths. (Gate: cbd union.)

Assets + build

  • build.rs in each binary: build-dep cbd-cli (default features), call generate_assets for its Command into OUT_DIR and, when CBD_ASSET_DIR is set, into that dir. (Gate: assets.)
  • devenv gen-cli-assets script: CBD_ASSET_DIR=$PWD/dist cargo build. (Gate: assets.)

Docs + verification

  • README: a CLI section (subcommands per binary, completions/man, the password-in-argv note); update the config section for auth/guard.
  • plan/summary.md: what was built + deviations.
  • cargo test --workspace green; clippy -D warnings, fmt, markdownlint clean (via devenv shell).