main.rs - CLI Interface
CLI Command Structure
// src/main.rs (lines 8-42)
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
command: Commands,
/// Path to local data directory (blockchain & wallet). Defaults to ./data
#[arg(long, short)]
data_dir: Option<PathBuf>,
}
#[derive(Subcommand)]
enum Commands {
/// Generate new wallet keypair
Keygen,
/// Show wallet address & balance
Balance,
/// Send coins to recipient
Send {
/// Recipient public key (hex)
to: String,
/// Amount in satoshi-like units
amount: u64,
},
/// Run full node (p2p + optional mining)
Node {
/// Enable mining loop (CPU-based)
#[arg(long)]
mine: bool,
/// TCP port to listen on
#[arg(long, default_value_t = 7000)]
port: u16,
/// Bootstrap peer list
#[arg(long)]
peers: Option<String>,
},
}Application Initialization
Command Implementations
Wallet Operations
Node Orchestration
HTTP Peer Synchronization
Synchronization Protocol Breakdown
Step
Operation
Purpose
Task Lifecycle Management
Background Task Spawning
Graceful Shutdown
Integration with Radio Systems
Error Handling Strategy
Last updated