Skip to content

cli/geolocation: convert user verbs to RFC-20 (async + ctx)#3798

Merged
ben-dz merged 10 commits into
mainfrom
bdz/geolocation-cli-rfc20-user
May 29, 2026
Merged

cli/geolocation: convert user verbs to RFC-20 (async + ctx)#3798
ben-dz merged 10 commits into
mainfrom
bdz/geolocation-cli-rfc20-user

Conversation

@ben-dz
Copy link
Copy Markdown
Contributor

@ben-dz ben-dz commented May 28, 2026

Summary

Convert all 9 doublezero geolocation user ... verbs to the RFC-20 async fn execute(ctx, client, out) form. Per RFC-20 §3 and §5, every verb in a module crate must be async fn and receive environment-derived configuration through CliContext.

This is PR 3 of a stack. Stacked on #3797 (probe verb conversion). After #3792 and #3797 land, this rebases onto main.

What changes

  • Each of the 9 user verb files (create, update, delete, get, list, add_target, remove_target, set_result_destination, update_payment_status) now exposes pub async fn execute<C: GeoCliCommand, W: Write>(self, ctx: &CliContext, client: &C, out: &mut W) -> eyre::Result<()>.
  • A tracing::debug!(env = %ctx.env, ..., "geolocation user <verb>") breadcrumb is the first statement of each verb body.
  • Verb tests use the existing block_on helper and build a CliContext via doublezero_cli_core::testing::cli_context_default_for_tests().
  • All 9 UserCommands::* arms in GeolocationCommand::execute now .await.

What stays the same

  • All verb arguments, output, JSON schemas, exit codes unchanged.
  • The Init arm stays sync — PR 4 converts it.
  • No new flags, no validator changes, no new public API.

RFC reference

RFC-20: CLI Standardization §3, §5

Testing Verification

  • make rust-lint clean in dev container (rustfmt nightly + clippy)
  • cargo test -p doublezero-geolocation-cli: 41/41
  • cargo test -p doublezero: 133/133

@ben-dz ben-dz marked this pull request as draft May 28, 2026 20:56
@ben-dz ben-dz force-pushed the bdz/geolocation-cli-rfc20-probe branch from 45925b0 to 4abda9a Compare May 28, 2026 20:58
@ben-dz ben-dz force-pushed the bdz/geolocation-cli-rfc20-user branch from e0d3ecd to 4cc99d9 Compare May 29, 2026 13:06
Base automatically changed from bdz/geolocation-cli-rfc20-probe to main May 29, 2026 13:54
@ben-dz ben-dz force-pushed the bdz/geolocation-cli-rfc20-user branch from 4cc99d9 to 123adfe Compare May 29, 2026 14:02
@ben-dz ben-dz marked this pull request as ready for review May 29, 2026 14:03
@ben-dz ben-dz merged commit f9ed0c8 into main May 29, 2026
37 of 38 checks passed
@ben-dz ben-dz deleted the bdz/geolocation-cli-rfc20-user branch May 29, 2026 14:35
ben-dz added a commit that referenced this pull request May 29, 2026
## Summary

Convert the `doublezero geolocation init` verb
(`InitProgramConfigCliCommand`) to the RFC-20 `async fn execute(ctx,
client, out)` form. With this, **every verb in
`doublezero-geolocation-cli` is fully RFC-20 conforming**.

This is PR 4 (the final PR) of a stack. Stacked on #3798. After #3792,
#3797, and #3798 land, this rebases onto main.

## What changes

- `init.rs::execute` becomes `pub async fn execute<C: GeoCliCommand, W:
Write>(self, ctx: &CliContext, client: &C, out: &mut W) ->
eyre::Result<()>` with a `tracing::debug!(env = %ctx.env, "geolocation
init")` breadcrumb.
- Test wrapped in `block_on`, `ctx` built via
`cli_context_default_for_tests()`.
- Dispatcher's `Self::Init` arm flipped to `.await`.

## Final state of the new module crate

After this PR merges, the `doublezero-geolocation-cli` crate satisfies
all of RFC-20's module-crate requirements:

- All 17 verbs (7 probe, 9 user, 1 init) are `async fn execute(ctx,
client, out)`.
- Shared validators come from `doublezero_cli_core::validators`.
- All output flows through the writer; no `println!`/`eprintln!` in
execute paths.
- Module exposes its backend client (`GeoCliCommand` trait) for mockable
testing.

## RFC reference

[RFC-20: CLI Standardization §3,
§5](../blob/main/rfcs/rfc20-cli-standardization.md)

## Testing Verification

- [x] `make rust-lint` clean in dev container
- [x] `cargo test -p doublezero-geolocation-cli`: 41/41
- [x] Final audit grep: zero `pub fn execute` matches in the crate (all
`pub async fn execute`); zero `crate::validators` imports; every
dispatcher arm uses `.await`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants