Skip to main content

claude_wrapper/command/
doctor.rs

1use crate::Claude;
2use crate::command::ClaudeCommand;
3use crate::error::Result;
4use crate::exec::{self, CommandOutput};
5
6/// Run `claude doctor` to check CLI health.
7///
8/// # Example
9///
10/// ```no_run
11/// use claude_wrapper::{Claude, ClaudeCommand, DoctorCommand};
12///
13/// # async fn example() -> claude_wrapper::Result<()> {
14/// let claude = Claude::builder().build()?;
15/// let output = DoctorCommand::new().execute(&claude).await?;
16/// println!("{}", output.stdout);
17/// # Ok(())
18/// # }
19/// ```
20#[derive(Debug, Clone, Default)]
21pub struct DoctorCommand;
22
23impl DoctorCommand {
24    #[must_use]
25    pub fn new() -> Self {
26        Self
27    }
28}
29
30impl ClaudeCommand for DoctorCommand {
31    type Output = CommandOutput;
32
33    fn args(&self) -> Vec<String> {
34        vec!["doctor".to_string()]
35    }
36
37    async fn execute(&self, claude: &Claude) -> Result<CommandOutput> {
38        exec::run_claude(claude, self.args()).await
39    }
40}
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn test_doctor_args() {
48        let cmd = DoctorCommand::new();
49        assert_eq!(cmd.args(), vec!["doctor"]);
50    }
51}