- 55 CLI files: handlers/, aitbc_cli/commands/, cli/core/, cli/utils/, top-level scripts
- Click-based files: print() -> click.echo()
- Library modules: print() -> logger.info/error/warning
- Fixed pre-existing indentation bugs in monitor.py dashboard function
- Fixed bare print() -> logger.info('') in chain_manager.py
- 0 remaining print() in production CLI code
- All files compile cleanly
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""Account handlers."""
|
|
|
|
import json
|
|
import sys
|
|
|
|
from aitbc import AITBCHTTPClient, NetworkError
|
|
import logging
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
def handle_account_get(args, default_rpc_url, output_format):
|
|
"""Handle account get command."""
|
|
rpc_url = args.rpc_url or default_rpc_url
|
|
chain_id = getattr(args, "chain_id", None)
|
|
|
|
if not args.address:
|
|
logger.error("Error: --address is required")
|
|
sys.exit(1)
|
|
|
|
logger.info(f"Getting account {args.address} from {rpc_url}...")
|
|
try:
|
|
params = {}
|
|
if chain_id:
|
|
params["chain_id"] = chain_id
|
|
|
|
http_client = AITBCHTTPClient(base_url=rpc_url, timeout=10)
|
|
account = http_client.get(f"/rpc/account/{args.address}", params=params)
|
|
if output_format(args) == "json":
|
|
logger.info(json.dumps(account, indent=2))
|
|
else:
|
|
render_mapping(f"Account {args.address}:", account)
|
|
except NetworkError as e:
|
|
logger.error(f"Error getting account: {e}")
|
|
sys.exit(1)
|
|
except Exception as e:
|
|
logger.error(f"Error getting account: {e}")
|
|
sys.exit(1)
|