diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-04-01 19:30:58 +0300 |
|---|---|---|
| committer | Can Celik <ogulcancelik@gmail.com> | 2026-04-01 19:32:26 +0300 |
| commit | ca4270b31fe93c180f7321cb4006cb5e7307d889 (patch) | |
| tree | 72628e311a1b8e5ebf78c74cbc61d990253dc4c4 /src/cli.rs | |
| parent | fb0c9717cfa961a47d63272e622e9e35a001082a (diff) | |
feat: add authoritative pi hook integration
Diffstat (limited to 'src/cli.rs')
| -rw-r--r-- | src/cli.rs | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -26,6 +26,7 @@ pub fn maybe_run(args: &[String]) -> std::io::Result<CommandOutcome> { "workspace" => run_workspace_command(&args[2..])?, "pane" => run_pane_command(&args[2..])?, "wait" => run_wait_command(&args[2..])?, + "integration" => run_integration_command(&args[2..])?, _ => return Ok(CommandOutcome::NotCli), }; @@ -90,6 +91,21 @@ fn run_wait_command(args: &[String]) -> std::io::Result<i32> { } } +fn run_integration_command(args: &[String]) -> std::io::Result<i32> { + let Some(subcommand) = args.first().map(|arg| arg.as_str()) else { + print_integration_help(); + return Ok(2); + }; + + match subcommand { + "install" => integration_install(&args[1..]), + _ => { + print_integration_help(); + Ok(2) + } + } +} + fn workspace_list(args: &[String]) -> std::io::Result<i32> { if !args.is_empty() { eprintln!("usage: herdr workspace list"); @@ -432,6 +448,30 @@ fn pane_run(args: &[String]) -> std::io::Result<i32> { })) } +fn integration_install(args: &[String]) -> std::io::Result<i32> { + let Some(target) = args.first().map(|arg| arg.as_str()) else { + eprintln!("usage: herdr integration install <pi>"); + return Ok(2); + }; + if args.len() != 1 { + eprintln!("usage: herdr integration install <pi>"); + return Ok(2); + } + + match target { + "pi" => { + let path = crate::integration::install_pi()?; + println!("installed pi integration to {}", path.display()); + Ok(0) + } + _ => { + eprintln!("unknown integration target: {target}"); + eprintln!("currently supported: pi"); + Ok(2) + } + } +} + fn wait_output(args: &[String]) -> std::io::Result<i32> { let Some(raw_pane_id) = args.first() else { eprintln!("usage: herdr wait output <pane_id> --match <text> [--source visible|recent] [--lines N] [--timeout MS] [--regex]"); @@ -743,6 +783,11 @@ fn print_wait_help() { ); } +fn print_integration_help() { + eprintln!("herdr integration commands:"); + eprintln!(" herdr integration install pi"); +} + fn _print_json<T: Serialize>(value: &T) { println!("{}", serde_json::to_string(value).unwrap()); } |
