#[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 AutoModeConfigCommand;
impl AutoModeConfigCommand {
#[must_use]
pub fn new() -> Self {
Self
}
}
impl ClaudeCommand for AutoModeConfigCommand {
type Output = CommandOutput;
fn args(&self) -> Vec<String> {
vec!["auto-mode".to_string(), "config".to_string()]
}
#[cfg(feature = "async")]
async fn execute(&self, claude: &Claude) -> Result<CommandOutput> {
exec::run_claude(claude, self.args()).await
}
}
#[derive(Debug, Clone, Default)]
pub struct AutoModeDefaultsCommand;
impl AutoModeDefaultsCommand {
#[must_use]
pub fn new() -> Self {
Self
}
}
impl ClaudeCommand for AutoModeDefaultsCommand {
type Output = CommandOutput;
fn args(&self) -> Vec<String> {
vec!["auto-mode".to_string(), "defaults".to_string()]
}
#[cfg(feature = "async")]
async fn execute(&self, claude: &Claude) -> Result<CommandOutput> {
exec::run_claude(claude, self.args()).await
}
}
#[derive(Debug, Clone, Default)]
pub struct AutoModeCritiqueCommand {
model: Option<String>,
}
impl AutoModeCritiqueCommand {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn model(mut self, model: impl Into<String>) -> Self {
self.model = Some(model.into());
self
}
}
impl ClaudeCommand for AutoModeCritiqueCommand {
type Output = CommandOutput;
fn args(&self) -> Vec<String> {
let mut args = vec!["auto-mode".to_string(), "critique".to_string()];
if let Some(ref model) = self.model {
args.push("--model".to_string());
args.push(model.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 config_command_args() {
let cmd = AutoModeConfigCommand::new();
assert_eq!(
ClaudeCommand::args(&cmd),
vec!["auto-mode".to_string(), "config".to_string()]
);
}
#[test]
fn defaults_command_args() {
let cmd = AutoModeDefaultsCommand::new();
assert_eq!(
ClaudeCommand::args(&cmd),
vec!["auto-mode".to_string(), "defaults".to_string()]
);
}
#[test]
fn critique_command_defaults_omit_model() {
let cmd = AutoModeCritiqueCommand::new();
let args = ClaudeCommand::args(&cmd);
assert_eq!(args, vec!["auto-mode".to_string(), "critique".to_string()]);
}
#[test]
fn critique_command_with_model() {
let cmd = AutoModeCritiqueCommand::new().model("opus");
let args = ClaudeCommand::args(&cmd);
assert_eq!(
args,
vec![
"auto-mode".to_string(),
"critique".to_string(),
"--model".to_string(),
"opus".to_string(),
]
);
}
}