Skip to main content

vv_agent/runtime/background_sessions/
options.rs

1use std::collections::BTreeMap;
2use std::path::PathBuf;
3use std::process::Child;
4use std::time::Instant;
5
6#[derive(Debug, Clone, Default)]
7pub struct BackgroundSessionStartOptions {
8    pub stdin: Option<String>,
9    pub auto_confirm: bool,
10    pub shell: Option<String>,
11    pub windows_shell_priority: Option<Vec<String>>,
12    pub env: Option<BTreeMap<String, String>>,
13}
14
15pub struct BackgroundSessionAdoptOptions {
16    pub command: String,
17    pub cwd: PathBuf,
18    pub timeout_seconds: u64,
19    pub child: Child,
20    pub output_path: PathBuf,
21    pub shell: Option<String>,
22    pub started_at: Option<Instant>,
23}
24
25impl BackgroundSessionAdoptOptions {
26    pub fn new(
27        command: impl Into<String>,
28        cwd: impl Into<PathBuf>,
29        timeout_seconds: u64,
30        child: Child,
31        output_path: impl Into<PathBuf>,
32    ) -> Self {
33        Self {
34            command: command.into(),
35            cwd: cwd.into(),
36            timeout_seconds,
37            child,
38            output_path: output_path.into(),
39            shell: None,
40            started_at: None,
41        }
42    }
43
44    pub fn with_shell(mut self, shell: impl Into<String>) -> Self {
45        self.shell = Some(shell.into());
46        self
47    }
48
49    pub fn with_started_at(mut self, started_at: Instant) -> Self {
50        self.started_at = Some(started_at);
51        self
52    }
53}