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