cli/serviceability: rewrite location get to rfc-20 conforming pattern#3757
cli/serviceability: rewrite location get to rfc-20 conforming pattern#3757juan-malbeclabs wants to merge 1 commit into
Conversation
5f73c25 to
c7133f3
Compare
2fb2f5a to
8d806a7
Compare
|
Today Can we either mirror the |
f2a46ac to
475a322
Compare
8d806a7 to
5056078
Compare
RFC-20 implementation stack
This PR is part of a 9-PR chain delivering RFC-20: CLI standardization. Each PR's diff is only its own contribution; reviewers should consume them in order.
doublezero-cli-corefoundation crate +solana_l1_rpc_url--solana-url+--log-verboseglobal flags + tracing initCliContextbuilt inmain+ centralized error renderingdoublezero_cli→doublezero-serviceability-clilocation getas the async +CliContextreference verbdocs/cli-standard.md+CLAUDE.mdpointerServiceabilityCommandenum + async dispatcher#[command(flatten)]+ collapse binary dispatchThis PR: #3757 — position 5 of 9. Previous: #3756 · Next: #3758
Summary of Changes
location getto the RFC-20 conforming verb pattern as the project's reference (smartcontract/cli/src/location/get.rs).GetLocationCliCommand::executeis nowasync fn, takes&CliContextas its first non-self argument, and emits atracing::debug!event so-vsurfaces what the verb is doing.doublezero_cli_core::testing::cli_context_default_for_tests()helper and exercise the new async signature via a smalltokiocurrent-thread runtime in the existing#[test]. Backend stays mocked throughMockCliCommand(auto-generated by#[automock]).client/doublezeroandcontrolplane/doublezero-adminto.awaitthe new method. Thedoublezero-adminbinary gets adoublezero-cli-coredep plus a smallCliContextbuild at startup (matching thedoublezerobinary's pattern) so the new verb is callable end-to-end.Diff Breakdown
One verb migrated end-to-end (async +
CliContext+ tracing + shared test helper); two binaries updated to.awaitthe new dispatch arm.Key files (click to expand)
smartcontract/cli/src/location/get.rs- convertsexecutetoasync fn (self, ctx, client, out), adds thetracing::debug!event, rewrites the unit test to usecli_context_default_for_tests()and a smalltokiocurrent-thread runtime around the awaited call.client/doublezero/src/main.rs- one-line change:LocationCommands::Get(args) => args.execute(&ctx, &client, &mut handle).await.controlplane/doublezero-admin/src/main.rs- same one-line dispatch change plus aCliContextBuilder::new().with_env(...).build()?block at startup so&ctxis available.controlplane/doublezero-admin/Cargo.toml,smartcontract/cli/Cargo.toml- adddoublezero-cli-coreandtracingdeps respectively.Testing Verification
cargo test -p doublezero-serviceability-cli location::getpasses (the rewritten test exercises pubkey lookup, code lookup, and the not-found error path through the async signature).make rust-testgreen workspace-wide.make rust-lintclean.doublezero location get --helpshows the same--codeand--jsonflags as before; behavior unchanged from the user's perspective.jo/4-cli-rename-serviceability; the diff shown is only this PR's contribution.