Commit c72f6d3
feat(cli): integrate Node API with all CLI commands
Complete integration of wraith-cli with wraith-core Node API, replacing
12 placeholder implementations that displayed misleading "Phase 7
protocol integration" warnings.
## Technical Changes
### New Imports and Dependencies
- Added wraith_core::node::{Node, NodeConfig} integration
- Added wraith_core::node::session::PeerId type support
- Added wraith_core::node::identity::TransferId for transfer tracking
- Added Arc<Node> for concurrent access patterns
- Added Duration support for timeout handling
### Helper Functions Added (4 new)
- parse_peer_id(s: &str) -> Result<PeerId>: Parses 64-char hex strings
to 32-byte peer IDs with comprehensive validation
- parse_transfer_id(s: &str) -> Result<TransferId>: Parses hex strings
to 32-byte transfer IDs for status queries
- format_duration(d: Duration) -> String: Human-readable duration
formatting (Xh Ym Zs format)
- create_node_config(config: &Config) -> NodeConfig: Converts CLI
configuration to Node API configuration structure
### Commands Integrated (12 total)
1. send: Full Node API integration with session establishment,
file transfer via node.send_file(), progress monitoring using
node.get_transfer_progress(), and completion waiting via
node.wait_for_transfer()
2. receive: Node listening mode with incoming transfer monitoring,
real-time progress display, and graceful Ctrl+C shutdown
3. daemon: Background node with node.start(), session monitoring,
transfer tracking, 5-second status updates, and clean shutdown
4. batch: Sequential multi-file transfers to single peer using
node.send_file() per file with individual progress tracking
5. status: Configuration display with runtime metrics indication
(daemon IPC integration noted for future live data)
6. peers --query: Full DHT integration using node.discover_peer()
for peer address lookup in distributed hash table
7. peers --list: Configuration display with session query support
(daemon IPC noted for active session listing)
8. health: Comprehensive health check validating configuration,
node creation (Node::new_random()), and identity generation
9. metrics: Configuration and feature display in text/JSON formats
(daemon IPC noted for runtime performance metrics)
10. info: Node identity display showing Ed25519 node ID (32-byte
public key) and X25519 key for Noise handshakes
11. keygen: Already complete - no changes needed
12. config: Connection testing noted for daemon IPC integration
### Async Implementation
- Proper tokio runtime integration with #[tokio::main]
- Graceful shutdown using tokio::signal::ctrl_c()
- Arc-wrapped nodes for concurrent background task access
- Correct .await usage for all Node API async methods
### Error Handling
- Comprehensive anyhow::Result propagation
- User-friendly error messages for common failures
- Peer ID validation (64 hex chars, valid hex)
- Path sanitization maintained for security
### Code Removed
- 12 "Phase 7 protocol integration" eprintln! warnings
- Obsolete placeholder implementations
- Unused test helper functions
## Impact
- CLI commands now functional with real Node API
- No more misleading Phase 7 warnings
- Proper async lifecycle management
- Foundation for IPC daemon queries (future work)
## Quality Assurance
- cargo fmt --all -- --check: PASS
- cargo clippy --workspace -- -D warnings: PASS (0 warnings)
- cargo test --workspace: PASS (545+ tests)
- cargo build --release: PASS
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent 0172de0 commit c72f6d3
1 file changed
+336
-239
lines changed
0 commit comments