cli: fold 5 binary-local diagnostic verbs into ServiceabilityCommand#3826
Merged
Conversation
Migrate version, account, accounts, log, and subscribe from the binary's top-level Command enum into ServiceabilityCommand per RFC-20. Each verb now takes &CliContext + generic &C: CliCommand + &mut W writer and is async. Add --json to account, accounts, and log (RFC-20 §Output). Add client_version field to CliContext so the version verb reads the build string from context instead of a passed parameter. Replace println!/ eprintln! in subscribe with writeln!/tracing. Subscribe uses get_all() snapshot instead of the blocking websocket loop (DZClient::subscribe takes FnMut which is incompatible with mockall's #[automock]). Fixes #1459
Switch account/log validators from validate_pubkey_or_code to validate_pubkey since these verbs only accept pubkeys. Add tracing::warn for transaction fetch failures. Remove dead --json flag from accounts (output is always JSON). Add binary-level subscribe override using real DZClient::subscribe for live streaming.
…ation Update Account, Accounts, and Log command dispatch in doublezero-admin to use the new (&CliContext, &client, &mut writer).await signature. Merge two use-statements in client/doublezero to satisfy rustfmt.
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.
Summary of Changes
Moves 5 diagnostic CLI verbs (
version,account,accounts,log,subscribe) from binary-local dispatch into the sharedServiceabilityCommandenum, conforming them to the RFC-20 async pattern (async fn execute<C: CliCommand, W: Write>(self, ctx: &CliContext, client: &C, out: &mut W)).client_versionfield toCliContextand builder; addedget_account_dataandget_transactionsmethods toCliCommandtrait; re-exportedDZTransactionfrom SDKC: CliCommand+&CliContext+&mut Wwriter pattern. Added--jsonflag toaccountandlogverbs with structured serializable output typesServiceabilityCommand(withaccountsandsubscribehidden); binaryCommandenum slimmed; binary-level override wired forsubscribeto use real websocket streamingMockCliCommand, covering table output, JSON output, error paths, and parse verificationFixes malbeclabs/infra#1459
Testing Verification
cargo test -p doublezero-serviceability-cli --lib)cargo test -p doublezero-cli-core --lib)cargo test -p doublezero-sdk --lib)