How tmtmtoo/cx works
Project type and purpose
• This is a Rust-based CLI utility (“cx”) that implements two subcommands for managing external command executions: “retry” (retry until success) and “supervise” (re-execute on failure up to a limit). It is a single binary, not a server or distributed system.
File structure
• Top-level: Cargo.toml, src/, tests/, GitHub CI configs, Makefile.
• src/main.rs: entry point, parses CLI flags/subcommands.
• src/app.rs + src/app/: contains the core application logic (component orchestrators, retry.rs, supervise.rs).
• src/app/components/: building blocks for execution (cmd_executor.rs, cmd_not_found.rs, wait.rs).
• src/config.rs: CLI → internal config model.
• src/io/: trait for executing commands, with tokio_impl.rs implementation.
• tests/: unit tests for retry and supervise modules.
README for additional insights
• Confirms two subcommands, each with “count” and “interval” options, invoking arbitrary shell commands.
• No external services or databases—pure local process execution.
• Break the binary into “CLI”, “Config”, “Controllers”, “Components”, “I/O Abstraction”, “OS Shell”.
• Trait boundary between executor logic and its tokio_impl.
• Callouts for test modules to demonstrate how the I/O trait enables unit testing.