Expand description
§CLI Bridge
This module provides a CLI integration bridge that allows any CLI tool to easily integrate into the ipckit ecosystem, enabling real-time communication with frontends. Similar to how Docker CLI integrates with Docker Desktop.
§Features
- Minimal invasiveness - existing CLI only needs minimal modifications
- Automatic output capture (stdout/stderr)
- Progress bar parsing
- Bidirectional communication (CLI can send events, frontend can send commands)
§Example
ⓘ
use ipckit::{CliBridge, WrappedCommand};
// Method 1: Direct bridge usage
let bridge = CliBridge::connect()?;
bridge.register_task("My CLI Task", "build")?;
bridge.log("info", "Starting build...");
for i in 0..100 {
if bridge.is_cancelled() {
bridge.fail("Cancelled by user");
return Ok(());
}
bridge.set_progress(i + 1, Some(&format!("Step {}/100", i + 1)));
}
bridge.complete(json!({"success": true}));
// Method 2: Wrap existing command
let output = WrappedCommand::new("cargo")
.args(["build", "--release"])
.task("Build Project", "build")
.progress_parser(parsers::PercentageParser)
.run()?;Modules§
- parsers
- Built-in progress parsers.
Structs§
- CliBridge
- CLI Bridge for integrating CLI tools with ipckit.
- CliBridge
Config - CLI bridge configuration.
- Command
Output - Output from a wrapped command.
- Progress
Info - Progress information parsed from output.
- Wrapped
Child - A wrapped child process.
- Wrapped
Command - A wrapped command that integrates with the CLI bridge.
- Wrapped
Writer - A writer that wraps stdout/stderr and forwards to the server.
Enums§
- Output
Type - Output type for wrapped writers.
Traits§
- Progress
Parser - Trait for parsing progress from output lines.