use anyhow::Result;
use clap::Subcommand;
pub mod bench;
mod bench_stt;
pub mod devices;
pub mod doctor;
pub mod init;
pub mod install_macos_bundle;
pub mod list;
#[cfg(feature = "agent-access")]
pub mod mcp;
pub mod notes;
pub mod qualify;
pub mod rec;
pub mod record;
pub mod repair;
pub mod show;
#[derive(Subcommand, Debug)]
pub enum Command {
Init(init::Args),
Devices(devices::Args),
Record(record::Args),
Rec(rec::Args),
List(list::Args),
Show(show::Args),
Notes(notes::Args),
Doctor(doctor::Args),
Bench(bench::BenchArgs),
Repair(repair::Args),
InstallMacosBundle(install_macos_bundle::Args),
Qualify(qualify::Args),
#[cfg(feature = "agent-access")]
Mcp(mcp::Args),
}
pub async fn run(cmd: Command) -> Result<()> {
match cmd {
Command::Init(a) => init::run(a).await,
Command::Record(a) => record::run(a).await,
Command::Rec(a) => rec::run(a).await,
Command::Devices(a) => devices::run(a),
Command::List(a) => list::run(a).await,
Command::Show(a) => show::run(a).await,
Command::Notes(a) => notes::run(a).await,
Command::Doctor(a) => doctor::run(a).await,
Command::Bench(a) => bench::run(a).await,
Command::Repair(a) => repair::run(a).await,
Command::Qualify(a) => qualify::run(&a),
Command::InstallMacosBundle(a) => install_macos_bundle::run(&a),
#[cfg(feature = "agent-access")]
Command::Mcp(a) => mcp::run(a).await,
}
}
#[cfg(test)]
#[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
mod tests {
use super::*;
#[tokio::test]
async fn test_run_dispatches_list_command_to_list_run() {
let dir = tempfile::tempdir().unwrap();
run(Command::List(list::Args {
root: Some(dir.path().to_path_buf()),
}))
.await
.unwrap();
}
#[tokio::test]
async fn test_run_dispatches_show_command_and_propagates_resolve_error() {
let dir = tempfile::tempdir().unwrap();
let err = run(Command::Show(show::Args {
id_or_folder: "missing".into(),
root: Some(dir.path().to_path_buf()),
no_transcript: false,
}))
.await
.unwrap_err();
assert!(err.to_string().contains("missing"));
}
#[tokio::test]
async fn test_run_dispatches_doctor_command() {
let dir = tempfile::tempdir().unwrap();
run(Command::Doctor(doctor::Args {
root: Some(dir.path().to_path_buf()),
check_tap: false,
check_sck: false,
fix: false,
sign_self: None,
}))
.await
.unwrap();
}
#[tokio::test]
async fn test_run_dispatches_repair_command_and_propagates_resolve_error() {
let dir = tempfile::tempdir().unwrap();
let err = run(Command::Repair(repair::Args {
id_or_folder: "missing".into(),
root: Some(dir.path().to_path_buf()),
}))
.await
.unwrap_err();
assert!(err.to_string().contains("missing"));
}
}