mirror of https://github.com/jackwener/wx-cli.git
1.8 KiB
1.8 KiB
| estimated_steps | estimated_files | skills_used |
|---|---|---|
| 14 | 16 |
T01: Add global --tcp CLI flag and wire into transport module
Add --tcp flag as a global argument on the root Cli struct in src/cli/mod.rs, not on individual subcommands. The flag takes Option<String> (e.g., Some("127.0.0.1:9876")). Wire this through the dispatch() function so every command path receives the TCP address. Modify all cmd_* functions in src/cli/ to accept an optional tcp_addr: Option<&str> parameter. Update src/cli/transport.rs:
- Add
send_tcp(req: Request, addr: &str) -> Result<Response>function usingstd::net::TcpStreamwith 15s connect timeout and 120s read/write timeout - Add
is_alive_tcp(addr: &str) -> boolfor TCP liveness check - Update
send()to accepttcp_addr: Option<&str>, routing tosend_tcpwhen present - Update
is_alive()to accepttcp_addr: Option<&str>, routing tois_alive_tcpwhen present - Update
ensure_daemon()— when --tcp is specified, do NOT auto-start daemon (user explicitly chose TCP); if connection fails, hard error with clear message
Must-haves:
- 15s connect timeout on TcpStream
- 120s read/write timeout
- No silent fallback when --tcp specified
- Hard error with address and OS error on connection failure
Constraints:
- Use std::net::TcpStream (blocking, since CLI is sync)
- Keep #[cfg(unix)] / #[cfg(windows)] guards intact for local transport paths
Inputs
src/cli/mod.rssrc/cli/transport.rssrc/cli/daemon_cmd.rssrc/cli/sessions.rssrc/ipc.rs
Expected Output
src/cli/mod.rssrc/cli/transport.rs
Verification
cargo check 2>&1 | tail -5; grep -c 'tcp: Option' src/cli/mod.rs; grep -q 'send_tcp' src/cli/transport.rs; grep -q 'is_alive_tcp' src/cli/transport.rs