Skip to main content

claude_code/commands/
doctor.rs

1use std::time::Duration;
2
3use super::command::ClaudeCommandRequest;
4
5#[derive(Debug, Clone)]
6pub struct ClaudeDoctorRequest {
7    press_enter: bool,
8    timeout: Option<Duration>,
9}
10
11impl ClaudeDoctorRequest {
12    pub fn new() -> Self {
13        Self {
14            press_enter: true,
15            timeout: None,
16        }
17    }
18
19    /// Some `claude doctor` versions wait for `Enter` before exiting. When enabled (default),
20    /// the wrapper sends a single newline on stdin so the command can terminate cleanly.
21    pub fn press_enter(mut self, press_enter: bool) -> Self {
22        self.press_enter = press_enter;
23        self
24    }
25
26    pub fn timeout(mut self, timeout: Duration) -> Self {
27        self.timeout = Some(timeout);
28        self
29    }
30
31    pub fn into_command(self) -> ClaudeCommandRequest {
32        let mut cmd = ClaudeCommandRequest::new(["doctor"]);
33        if self.press_enter {
34            cmd = cmd.stdin_bytes(b"\n".to_vec());
35        }
36        if let Some(timeout) = self.timeout {
37            cmd = cmd.timeout(timeout);
38        }
39        cmd
40    }
41}
42
43impl Default for ClaudeDoctorRequest {
44    fn default() -> Self {
45        Self::new()
46    }
47}