claude_wrapper/command/
doctor.rs1use crate::Claude;
2use crate::command::ClaudeCommand;
3use crate::error::Result;
4use crate::exec::{self, CommandOutput};
5
6#[derive(Debug, Clone, Default)]
21pub struct DoctorCommand {
22 json: bool,
23}
24
25impl DoctorCommand {
26 #[must_use]
27 pub fn new() -> Self {
28 Self::default()
29 }
30
31 #[must_use]
33 pub fn json(mut self) -> Self {
34 self.json = true;
35 self
36 }
37}
38
39impl ClaudeCommand for DoctorCommand {
40 type Output = CommandOutput;
41
42 fn args(&self) -> Vec<String> {
43 let mut args = vec!["doctor".to_string()];
44 if self.json {
45 args.push("--json".to_string());
46 }
47 args
48 }
49
50 async fn execute(&self, claude: &Claude) -> Result<CommandOutput> {
51 exec::run_claude(claude, self.args()).await
52 }
53}
54
55#[cfg(test)]
56mod tests {
57 use super::*;
58
59 #[test]
60 fn test_doctor_args() {
61 let cmd = DoctorCommand::new();
62 assert_eq!(cmd.args(), vec!["doctor"]);
63 }
64
65 #[test]
66 fn test_doctor_json_flag() {
67 let cmd = DoctorCommand::new().json();
68 assert_eq!(cmd.args(), vec!["doctor", "--json"]);
69 }
70}