refactor(tusdt-cli): adopt btcli architecture patterns - #9
Merged
Conversation
Replace scattered try/except/print_error blocks with centralized CLIContext (run_read/submit choke points), shared Click option decorators (globals.py), and structured Output rendering. - Add errors.py (ErrorCode enum, TUSDTError, REMEDIATION) - Add logs.py (RichHandler, --quiet/-v/-vv verbosity ladder) - Add output.py (Output class, --json/--quiet support) - Add globals.py (shared Click options, defined once) - Add context.py (CLIContext: per-invocation state, uniform error handling, signer resolution, tx-result rendering) - Add justfile (8 dev targets: sync, lint, fmt, typecheck, test, cov, check, build) - Add 90 tests across 7 modules (pytest, CliRunner, mocks) - Add connection retry (3 attempts, exponential backoff) - Add env var config (TUSDT_RPC, TUSDT_NETWORK, etc.) - Add shell completions (bash/zsh/fish via Click) - Add py.typed marker, CI workflow, pre-commit config - ContractError now inherits from TUSDTError - Monkey-patch wrapped in explicit _apply_metadata_patch() - All 7 command files refactored to CLIContext pattern (22% fewer lines, higher coverage) - Fix 11 ty type-checker warnings → 0
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.
Replace scattered try/except/print_error blocks with centralized
CLIContext (run_read/submit choke points), shared Click option
decorators (globals.py), and structured Output rendering.
error handling, signer resolution, tx-result rendering)
test, cov, check, build)
(22% fewer lines, higher coverage)