#[cfg(feature = "async")]
use crate::Claude;
use crate::command::ClaudeCommand;
#[cfg(feature = "async")]
use crate::error::Result;
#[cfg(feature = "async")]
use crate::exec;
use crate::exec::CommandOutput;
#[derive(Debug, Clone, Default)]
pub struct UltrareviewCommand {
target: Option<String>,
json: bool,
timeout_minutes: Option<u32>,
}
impl UltrareviewCommand {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn target(mut self, target: impl Into<String>) -> Self {
self.target = Some(target.into());
self
}
#[must_use]
pub fn json(mut self) -> Self {
self.json = true;
self
}
#[must_use]
pub fn timeout(mut self, minutes: u32) -> Self {
self.timeout_minutes = Some(minutes);
self
}
}
impl ClaudeCommand for UltrareviewCommand {
type Output = CommandOutput;
fn args(&self) -> Vec<String> {
let mut args = vec!["ultrareview".to_string()];
if self.json {
args.push("--json".to_string());
}
if let Some(minutes) = self.timeout_minutes {
args.push("--timeout".to_string());
args.push(minutes.to_string());
}
if let Some(ref target) = self.target {
args.push(target.clone());
}
args
}
#[cfg(feature = "async")]
async fn execute(&self, claude: &Claude) -> Result<CommandOutput> {
exec::run_claude(claude, self.args()).await
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn ultrareview_defaults() {
assert_eq!(
ClaudeCommand::args(&UltrareviewCommand::new()),
vec!["ultrareview"]
);
}
#[test]
fn ultrareview_with_target_json_timeout() {
let cmd = UltrareviewCommand::new().target("123").json().timeout(45);
assert_eq!(
ClaudeCommand::args(&cmd),
vec!["ultrareview", "--json", "--timeout", "45", "123"]
);
}
#[test]
fn ultrareview_target_only() {
let cmd = UltrareviewCommand::new().target("main");
assert_eq!(ClaudeCommand::args(&cmd), vec!["ultrareview", "main"]);
}
#[test]
fn ultrareview_json_only() {
let cmd = UltrareviewCommand::new().json();
assert_eq!(ClaudeCommand::args(&cmd), vec!["ultrareview", "--json"]);
}
}