Skip to main content

claude_wrapper/command/
doctor.rs

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