Skip to content

refactor(tusdt-cli): adopt btcli architecture patterns - #9

Merged
Benup211 merged 1 commit into
mainfrom
refactor/cli-architecture
Jul 14, 2026
Merged

refactor(tusdt-cli): adopt btcli architecture patterns#9
Benup211 merged 1 commit into
mainfrom
refactor/cli-architecture

Conversation

@Benup211

Copy link
Copy Markdown
Collaborator

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

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
@Benup211
Benup211 merged commit 0b564f5 into main Jul 14, 2026
2 checks passed
@Benup211
Benup211 deleted the refactor/cli-architecture branch July 14, 2026 12:46
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.

1 participant