Skip to content

cli/geolocation: migrate into doublezero-geolocation-cli module crate#3792

Merged
ben-dz merged 4 commits into
mainfrom
bdz/geolocation-cli-rfc20-move
May 28, 2026
Merged

cli/geolocation: migrate into doublezero-geolocation-cli module crate#3792
ben-dz merged 4 commits into
mainfrom
bdz/geolocation-cli-rfc20-move

Conversation

@ben-dz
Copy link
Copy Markdown
Contributor

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

Summary

  • Move all doublezero geolocation subcommands into a new RFC-20-conforming module crate at crates/doublezero-geolocation-cli/.
  • Fold the hidden top-level doublezero init-geolocation-config into doublezero geolocation init (also hidden); both routes now share one code path.
  • Drop the redundant geolocation/config/{get,set} subtree — the unified doublezero config covers the same fields.

This is PR 1 of a stack. It is a pure structural move — verbs keep their current sync signatures and behavior. Subsequent PRs convert each verb to the RFC-20 async fn execute(ctx, client, out) form per RFC-20 §3 and §5.

What changes

  • New crate doublezero-geolocation-cli (library only) owns: GeolocationArgs, GeolocationCommand, the Init / Probe / User subtrees, and GeoCliCommand + GeoCliCommandImpl.
  • client/doublezero mounts Command::Geolocation(GeolocationArgs) and dispatches via the new crate's GeolocationCommand::execute. The binary's old wrapper at client/doublezero/src/cli/geolocation/ is deleted.
  • smartcontract/cli/src/{geoclicommand.rs, geolocation/} are gone; the geolocation dep is dropped from smartcontract/cli/Cargo.toml.
  • Validators across the moved files now import from doublezero_cli_core::validators::* (per RFC-20 §69) instead of the serviceability crate's local module.

What stays the same

  • doublezero geolocation probe ... and doublezero geolocation user ... are byte-identical in argument parsing and output.
  • All existing geolocation tests pass unchanged (modulo the trait-import path inside test modules).
  • The onchain doublezero-geolocation program and the geolocation SDKs (Go / Python / TypeScript) are untouched.

RFC reference

RFC-20: CLI Standardization

Testing Verification

  • cargo check --workspace clean
  • cargo test -p doublezero-geolocation-cli: 41/41 pass
  • cargo test -p doublezero: 133/133 pass
  • cargo test -p doublezero-serviceability-cli and doublezero-cli-core unaffected
  • doublezero geolocation --help shows the same probe / user tree as before
  • doublezero geolocation init --help works (new route)
  • doublezero init-geolocation-config no longer exists (removed; CHANGELOG updated)

@ben-dz ben-dz force-pushed the bdz/geolocation-cli-rfc20-move branch from 6f4e3f8 to 5e68bb7 Compare May 28, 2026 18:07
@ben-dz ben-dz requested a review from juan-malbeclabs May 28, 2026 18:16
Copy link
Copy Markdown
Contributor

@juan-malbeclabs juan-malbeclabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ben-dz ben-dz enabled auto-merge (squash) May 28, 2026 20:43
@ben-dz ben-dz merged commit da21596 into main May 28, 2026
37 of 38 checks passed
@ben-dz ben-dz deleted the bdz/geolocation-cli-rfc20-move branch May 28, 2026 20:53
ben-dz added a commit that referenced this pull request May 29, 2026
## Summary

Convert all 7 `doublezero geolocation probe ...` verbs to the RFC-20
`async fn execute(ctx, client, out)` form. Per [RFC-20
§3](../blob/main/rfcs/rfc20-cli-standardization.md), every verb in a
module crate must be `async fn` and receive environment-derived
configuration through `CliContext`.

This is PR 2 of a stack. Stacked on #3792 (move-as-is). After #3792
lands, this rebases onto main.

## What changes

- Each of the 7 probe verb files (`create`, `update`, `delete`, `get`,
`list`, `add_parent`, `remove_parent`) 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 probe <verb>")`
breadcrumb is the first statement of each verb body.
- Verb tests use the existing `block_on` helper (mirroring
`smartcontract/cli/src/location/get.rs`) and build a `CliContext` via
`doublezero_cli_core::testing::cli_context_default_for_tests()`.
- `GeolocationCommand::execute` in `cli.rs` is `async fn`; all 7 Probe
arms now `.await`.
- The binary's call site `args.command.execute(&ctx, &geo_cli, &mut
handle).await`.

## What stays the same

- All verb arguments, output, JSON schemas, exit codes unchanged.
- `Init` and all 9 `User::*` dispatcher arms stay sync — PRs 3 and 4
convert those.
- No new flags, no validator changes, no new public API.

## 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 (rustfmt nightly + clippy)
- [x] `cargo test -p doublezero-geolocation-cli`: 41/41
- [x] `cargo test -p doublezero`: 133/133
ben-dz added a commit that referenced this pull request May 29, 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](../blob/main/rfcs/rfc20-cli-standardization.md), 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](../blob/main/rfcs/rfc20-cli-standardization.md)

## Testing Verification

- [x] `make rust-lint` clean in dev container (rustfmt nightly + clippy)
- [x] `cargo test -p doublezero-geolocation-cli`: 41/41
- [x] `cargo test -p doublezero`: 133/133
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants