Skip to content

cli/serviceability: rewrite location get to rfc-20 conforming pattern#3757

Open
juan-malbeclabs wants to merge 1 commit into
jo/4-cli-rename-serviceabilityfrom
jo/5-cli-location-get-conforming-verb
Open

cli/serviceability: rewrite location get to rfc-20 conforming pattern#3757
juan-malbeclabs wants to merge 1 commit into
jo/4-cli-rename-serviceabilityfrom
jo/5-cli-location-get-conforming-verb

Conversation

@juan-malbeclabs
Copy link
Copy Markdown
Contributor

@juan-malbeclabs juan-malbeclabs commented May 22, 2026

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.

# PR Scope
1 #3753 doublezero-cli-core foundation crate + solana_l1_rpc_url
2 #3754 --solana-url + --log-verbose global flags + tracing init
3 #3755 CliContext built in main + centralized error rendering
4 #3756 rename doublezero_clidoublezero-serviceability-cli
5 #3757 rewrite location get as the async + CliContext reference verb
6 #3758 docs/cli-standard.md + CLAUDE.md pointer
7 #3759 move per-resource subcommand wrappers into the module crate
8 #3760 add ServiceabilityCommand enum + async dispatcher
9 #3761 #[command(flatten)] + collapse binary dispatch

This PR: #3757 — position 5 of 9. Previous: #3756 · Next: #3758


Summary of Changes

  • Migrates location get to the RFC-20 conforming verb pattern as the project's reference (smartcontract/cli/src/location/get.rs). GetLocationCliCommand::execute is now async fn, takes &CliContext as its first non-self argument, and emits a tracing::debug! event so -v surfaces what the verb is doing.
  • Updates the verb's unit test to consume the shared doublezero_cli_core::testing::cli_context_default_for_tests() helper and exercise the new async signature via a small tokio current-thread runtime in the existing #[test]. Backend stays mocked through MockCliCommand (auto-generated by #[automock]).
  • Updates the binary dispatch arms in client/doublezero and controlplane/doublezero-admin to .await the new method. The doublezero-admin binary gets a doublezero-cli-core dep plus a small CliContext build at startup (matching the doublezero binary's pattern) so the new verb is callable end-to-end.
  • The verb's user-facing args, flags, table layout, and JSON schema are unchanged. Other location verbs (Create, Update, List, Delete) keep their current sync signatures and migrate opportunistically per RFC-20's grandfathering clause.

Diff Breakdown

Category Files Lines (+/-) Net
Core logic 3 +43 / -11 +32
Tests 1 +14 / -3 +11
Config/build 2 +2 / -0 +2
Docs 1 +1 / -0 +1
Generated 1 +14 / -7 +7
Total 7 +74 / -21 +53

One verb migrated end-to-end (async + CliContext + tracing + shared test helper); two binaries updated to .await the new dispatch arm.

Key files (click to expand)
  • smartcontract/cli/src/location/get.rs - converts execute to async fn (self, ctx, client, out), adds the tracing::debug! event, rewrites the unit test to use cli_context_default_for_tests() and a small tokio current-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 a CliContextBuilder::new().with_env(...).build()? block at startup so &ctx is available.
  • controlplane/doublezero-admin/Cargo.toml, smartcontract/cli/Cargo.toml - add doublezero-cli-core and tracing deps respectively.

Testing Verification

  • cargo test -p doublezero-serviceability-cli location::get passes (the rewritten test exercises pubkey lookup, code lookup, and the not-found error path through the async signature).
  • make rust-test green workspace-wide.
  • make rust-lint clean.
  • doublezero location get --help shows the same --code and --json flags as before; behavior unchanged from the user's perspective.
  • Targets jo/4-cli-rename-serviceability; the diff shown is only this PR's contribution.

@vihu
Copy link
Copy Markdown
Contributor

vihu commented May 22, 2026

doublezero-admin now constructs a CliContext, but it only seeds .with_env(env_for_ctx) and drops the explicit admin globals (--url, --ws, --program-id, --keypair) that are still passed into DZClient.

Today location get only uses ctx.env for a debug log, so this is not a current output regression. But this PR makes location get the reference RFC-20 pattern, and future migrated verbs are expected to read backend/signing inputs from CliContext. In doublezero-admin, that would make migrated verbs see default env-derived values instead of the actual overrides used by DZClient.

Can we either mirror the client/doublezero/src/main.rs context-building behavior here or hold off on passing a partial context from doublezero-admin until it carries the same resolved inputs?

@juan-malbeclabs juan-malbeclabs force-pushed the jo/4-cli-rename-serviceability branch 2 times, most recently from f2a46ac to 475a322 Compare May 24, 2026 14:41
@juan-malbeclabs juan-malbeclabs force-pushed the jo/5-cli-location-get-conforming-verb branch from 8d806a7 to 5056078 Compare May 24, 2026 14:41
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.

2 participants