Skip to content

Registry 0.6.0: status-returning handlers, typed params, single exit mapping - #26

Open
samifouad wants to merge 1 commit into
mainfrom
kimi/registry-status-22
Open

samifouad wants to merge 1 commit into
mainfrom
kimi/registry-status-22

Conversation

@samifouad

Copy link
Copy Markdown
Member

What changed

Implements the 0.6.0 contract from #22 (rfd#61, approved):

  • Handlers return a status. CommandSpec/SubcommandSpec handlers are now fn(&Context) -> Result<ExitStatus, CommandError>. CommandError::Usage exits 2, CommandError::Runtime exits 1 (GNU convention), Ok(ExitStatus) carries the code (ExitStatus::SUCCESS in almost all cases, ExitStatus::from_code for commands whose contract promises a code).
  • One exit mapper. Registry::run(args) -> ExitCode parses, dispatches, prints every error in one format, and is the only place that maps to a process exit code — main becomes fn main() -> ExitCode { registry.run(std::env::args()) }. Consumers with special no-argument behavior (help with exit 0) check for an empty argv before calling run. The underlying dispatch() now propagates the handler's HandlerResult.
  • Typed params. Context::flag(), Context::param::<T>(), Context::param_or(), Context::param_list(); a bad value is a usage error in one format (invalid value for --port: …). ParamSpec gains kind: ParamKind::Value (last wins) / ParamKind::List (--tag a --tag b accumulates in order). Flag and param keys canonicalize to the spec name during parsing (-v reads as --verbose).
  • In-process command tests. Handlers write through Context::out()/Context::err(); Registry::run_captured(argv) returns (ExitCode, stdout, stderr) without spawning a process.
  • Docs say Deka, not Tana; README documents the new contract with a wire-up example.

Version bumped to 0.6.0; after merge this needs a v0.6.0 tag (release.yml publishes and verifies — tagging is Sami's).

Evidence

  • cargo test --all-features → 10 suites, 0 failures (47 lib tests including 6 new contract tests: exit-code mapping, captured output, parse-error format with suggestions, typed-param validation, list accumulation, canonical flag access)
  • cargo clippy --all-features --all-targets → 0 warnings
  • Revert proof: flattening the exit-code mapping to always-1 fails run_maps_handler_results_to_exit_codes_in_one_place (left: ExitCode(1), right: ExitCode(2))
  • Consumer tests (registry_bridge, context_env, context_bridge, context_extensions) migrated to the new signatures and pass; alias canonicalization is asserted in registry_bridge
  • Note: the repo's timing-sensitive update tests (health probe exceeded 2s, token temp-name race — the latter already filed as token_file: concurrent write_token races on temp name (flaky test on main) #24) flake intermittently on this loaded machine, on main as well; the full suite passed clean on the final run

closes #22
-kimi

…mapping

Breaking contract change (cli-core#22, rfd#61 approved):

- Command and subcommand handlers return Result<ExitStatus, CommandError>.
  CommandError::Usage exits 2, CommandError::Runtime exits 1; Ok(ExitStatus)
  carries the code. Registry::run(args) -> ExitCode parses, dispatches,
  prints every error in one format, and is the only place that maps to a
  process exit code — main becomes one line.
- Flag/param keys canonicalize to the spec name during parsing (-v reads
  as --verbose). Context gains typed accessors: flag(), param::<T>(),
  param_or(), param_list(); bad values are usage errors in one format.
- ParamSpec gains a kind: Value (last wins) or List (accumulates in order).
- Handlers write through Context::out()/err(); Registry::run_captured(argv)
  returns (ExitCode, stdout, stderr) so command tests run in-process.
- Module/crate docs say Deka, not Tana.

Consumer tests and README updated for the new signatures.

This branch was successfully deployed

2 active deployments
release — 780f9587 Deployed Oct 2, 2026 by samifouad via Publish deka-cli-core #8
public-ci — 780f9587 Deployed Oct 2, 2026 by samifouad via Build and test #24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Registry: handlers return an exit status, flags carry typed values

1 participant