claude_wrapper/command/
auto_mode.rs1#[cfg(feature = "async")]
14use crate::Claude;
15use crate::command::ClaudeCommand;
16#[cfg(feature = "async")]
17use crate::error::Result;
18#[cfg(feature = "async")]
19use crate::exec;
20use crate::exec::CommandOutput;
21
22#[derive(Debug, Clone, Default)]
40pub struct AutoModeConfigCommand;
41
42impl AutoModeConfigCommand {
43 #[must_use]
45 pub fn new() -> Self {
46 Self
47 }
48}
49
50impl ClaudeCommand for AutoModeConfigCommand {
51 type Output = CommandOutput;
52
53 fn args(&self) -> Vec<String> {
54 vec!["auto-mode".to_string(), "config".to_string()]
55 }
56
57 #[cfg(feature = "async")]
58 async fn execute(&self, claude: &Claude) -> Result<CommandOutput> {
59 exec::run_claude(claude, self.args()).await
60 }
61}
62
63#[derive(Debug, Clone, Default)]
68pub struct AutoModeDefaultsCommand;
69
70impl AutoModeDefaultsCommand {
71 #[must_use]
73 pub fn new() -> Self {
74 Self
75 }
76}
77
78impl ClaudeCommand for AutoModeDefaultsCommand {
79 type Output = CommandOutput;
80
81 fn args(&self) -> Vec<String> {
82 vec!["auto-mode".to_string(), "defaults".to_string()]
83 }
84
85 #[cfg(feature = "async")]
86 async fn execute(&self, claude: &Claude) -> Result<CommandOutput> {
87 exec::run_claude(claude, self.args()).await
88 }
89}
90
91#[derive(Debug, Clone, Default)]
113pub struct AutoModeCritiqueCommand {
114 model: Option<String>,
115}
116
117impl AutoModeCritiqueCommand {
118 #[must_use]
120 pub fn new() -> Self {
121 Self::default()
122 }
123
124 #[must_use]
126 pub fn model(mut self, model: impl Into<String>) -> Self {
127 self.model = Some(model.into());
128 self
129 }
130}
131
132impl ClaudeCommand for AutoModeCritiqueCommand {
133 type Output = CommandOutput;
134
135 fn args(&self) -> Vec<String> {
136 let mut args = vec!["auto-mode".to_string(), "critique".to_string()];
137 if let Some(ref model) = self.model {
138 args.push("--model".to_string());
139 args.push(model.clone());
140 }
141 args
142 }
143
144 #[cfg(feature = "async")]
145 async fn execute(&self, claude: &Claude) -> Result<CommandOutput> {
146 exec::run_claude(claude, self.args()).await
147 }
148}
149
150#[cfg(test)]
151mod tests {
152 use super::*;
153
154 #[test]
155 fn config_command_args() {
156 let cmd = AutoModeConfigCommand::new();
157 assert_eq!(
158 ClaudeCommand::args(&cmd),
159 vec!["auto-mode".to_string(), "config".to_string()]
160 );
161 }
162
163 #[test]
164 fn defaults_command_args() {
165 let cmd = AutoModeDefaultsCommand::new();
166 assert_eq!(
167 ClaudeCommand::args(&cmd),
168 vec!["auto-mode".to_string(), "defaults".to_string()]
169 );
170 }
171
172 #[test]
173 fn critique_command_defaults_omit_model() {
174 let cmd = AutoModeCritiqueCommand::new();
175 let args = ClaudeCommand::args(&cmd);
176 assert_eq!(args, vec!["auto-mode".to_string(), "critique".to_string()]);
177 }
178
179 #[test]
180 fn critique_command_with_model() {
181 let cmd = AutoModeCritiqueCommand::new().model("opus");
182 let args = ClaudeCommand::args(&cmd);
183 assert_eq!(
184 args,
185 vec![
186 "auto-mode".to_string(),
187 "critique".to_string(),
188 "--model".to_string(),
189 "opus".to_string(),
190 ]
191 );
192 }
193}