cli: build CliContext in main and centralize error rendering#3755
Open
juan-malbeclabs wants to merge 2 commits into
Open
cli: build CliContext in main and centralize error rendering#3755juan-malbeclabs wants to merge 2 commits into
juan-malbeclabs wants to merge 2 commits into
Conversation
7ab3a4b to
7a7f8b6
Compare
3ea897e to
02beec8
Compare
This was referenced May 22, 2026
Contributor
|
The bridge currently sets
|
7a7f8b6 to
19c7707
Compare
Replaces the three explicit if/else blocks that translated CliContext into DZClient::new arguments with a flat `any_url_explicit.then(...)` form. The behavior is identical: when no env or per-field override is present, all three fields stay None so DZClient falls through to the on-disk config; otherwise the resolved CliContext values flow through. Drops the assumption that env_explicit alone resolves URL/program-id fields: any explicit override (--url, --ws, --program-id) now also opts into using the resolved context, which keeps the bridge in step with the builder's WS-from-RPC derivation introduced in jo/1. Also corrects the stale comment that referenced `~/.config/solana/cli/config.yml`; DZClient actually reads `~/.config/doublezero/cli/config.yml`.
02beec8 to
d121d83
Compare
Contributor
Author
|
The change was applied to the corresponding PRs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: #3755 — position 3 of 9. Previous: #3754 · Next: #3756
Summary of Changes
CliContextonce at binary startup from--envand the per-field global overrides (--url,--ws,--solana-url,--keypair,--sock-file), per RFC-20 (§CliContext). The context resolves toEnvironment::default()(devnet) when--envis absent.DZClientcontinues to consume the legacyOption<String>tuple via a thin bridge that forwardsNonewhen neither--envnor a per-field override is set, preserving today's fall-back to~/.config/solana/cli/config.yml. Verbs that migrate to the RFC-20 module contract will consumeCliContextdirectly and the bridge shrinks.doublezero_cli_core::error::render_eyre. Replaces three ad-hoceprintln!("Error: {e}")sites inclient/doublezero/src/main.rs(env-parse failure, env-config resolution failure, top-level command failure) with a single helper that printsError: <head>followed by the full chain of causes on stderr.Diff Breakdown
Replaces the ad-hoc env-resolution tuple in
main.rswith aCliContextBuilderinvocation and unifies error rendering; no change to subcommand dispatch shape.Key files (click to expand)
client/doublezero/src/main.rs- constructsCliContextviaCliContextBuilderafterApp::parse(), bridges back toDZClient::newfor the legacyOption<String>signature without changing the no-flags fall-back behavior, and routes the three error-exit sites throughdoublezero_cli_core::error::render_eyre.Testing Verification
cargo check --workspaceclean.doublezero --env totally-bogus addressprints a single-lineError: Invalid environment ...on stderr (via the newrender_eyre) and exits 1, matching the previous behavior.doublezero --env devnet addressresolves and prints the address (CliContextpopulated fromEnvironment::Devnet);doublezero addresswith no flags still falls back to~/.config/solana/cli/config.ymlvia the bridge.jo/2-cli-global-flags; the diff shown is only this PR's contribution.