Skip to content

cli/serviceability: add ServiceabilityCommand enum with async dispatcher#3760

Open
juan-malbeclabs wants to merge 2 commits into
jo/7-cli-serviceability-move-cli-filesfrom
jo/8-cli-serviceability-command-enum
Open

cli/serviceability: add ServiceabilityCommand enum with async dispatcher#3760
juan-malbeclabs wants to merge 2 commits into
jo/7-cli-serviceability-move-cli-filesfrom
jo/8-cli-serviceability-command-enum

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: #3760 — position 8 of 9. Previous: #3759 · Next: #3761


Summary of Changes

  • Adds doublezero_serviceability_cli::cli::ServiceabilityCommand, the module crate's top-level subcommand enum per RFC-20 §Module contract item 2.
  • Aggregates 17 serviceability variants: Init, Migrate, Address, Balance, Config, GlobalConfig, Location, Exchange, Contributor, Permission, Tenant, Device, Link, AccessPass, User, Export, Keygen, Resource.
  • Implements async fn execute(ctx: &CliContext, client: &impl CliCommand, out: &mut impl Write) that owns the full per-resource dispatch tree currently inlined in client/doublezero/src/main.rs. The Location::Get arm forwards &ctx and is .awaited (matches the RFC-20 reference verb from cli/serviceability: rewrite location get to rfc-20 conforming pattern #3757); all other resource arms are sync.
  • Not yet wired into the unified binary. The next PR (actions: add missing go.{mod,sum} path #9) adds #[command(flatten)] Serviceability(ServiceabilityCommand) to the binary's Command enum and collapses main.rs's ~270-line match block to a single dispatch arm.

Diff Breakdown

Category Files Lines (+/-) Net
Core logic 1 +242 / -0 +242
Scaffolding 1 +1 / -0 +1
Docs 1 +1 / -0 +1
Total 3 +244 / -1 +243

Single new file in the library plus a one-line pub mod in cli/mod.rs. The enum is pub and reachable but currently has no in-tree consumer; it surfaces as the module crate's public mounting point ready for the binary to flatten.

Key files (click to expand)
  • smartcontract/cli/src/cli/command.rs (new) - the ServiceabilityCommand enum + async fn execute dispatcher. Forwards &CliContext only to verbs that consume it (today only LocationCommands::Get per cli/serviceability: rewrite location get to rfc-20 conforming pattern #3757); other arms ignore ctx. The AccessPassCommands::Fund arm preserves the existing stdin-reading behavior (std::io::stdin().lock()) since that interaction is part of the verb's contract today.
  • smartcontract/cli/src/cli/mod.rs - adds pub mod command;.

Testing Verification

  • cargo check --workspace clean.
  • make rust-test green workspace-wide (no behavior change — the new enum is unused by the binary in this PR).
  • make rust-lint clean.
  • cargo doc --no-deps -p doublezero-serviceability-cli succeeds and the new module appears.
  • Targets jo/7-cli-serviceability-move-cli-files; the diff shown is only this PR's contribution. Final PR actions: add missing go.{mod,sum} path #9 will flatten this enum into the binary and collapse main.rs dispatch.

Comment thread smartcontract/cli/src/cli/command.rs
@juan-malbeclabs juan-malbeclabs force-pushed the jo/7-cli-serviceability-move-cli-files branch from f274db8 to 17d3095 Compare May 24, 2026 14:42
@juan-malbeclabs juan-malbeclabs force-pushed the jo/8-cli-serviceability-command-enum branch from 5207968 to e562729 Compare May 24, 2026 14:42
…mmand

Pin the representative dispatch chains (location get, device interface
get, link create wan, access-pass fund, resource verify) plus the hidden
init/migrate variants to specific nested enum variants. Catches wrong
Subcommand attributes or misrouted nested enums before #3761 flattens
this enum into the doublezero binary.
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