1use crate::{CliOverridesPatch, ConfigOverride, FlagState};
2
3#[derive(Clone, Debug)]
5pub struct ExecRequest {
6 pub prompt: String,
7 pub ephemeral: bool,
8 pub ignore_rules: bool,
9 pub ignore_user_config: bool,
10 pub overrides: CliOverridesPatch,
11}
12
13impl ExecRequest {
14 pub fn new(prompt: impl Into<String>) -> Self {
15 Self {
16 prompt: prompt.into(),
17 ephemeral: false,
18 ignore_rules: false,
19 ignore_user_config: false,
20 overrides: CliOverridesPatch::default(),
21 }
22 }
23
24 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
25 self.overrides = overrides;
26 self
27 }
28
29 pub fn ephemeral(mut self, enable: bool) -> Self {
30 self.ephemeral = enable;
31 self
32 }
33
34 pub fn ignore_rules(mut self, enable: bool) -> Self {
35 self.ignore_rules = enable;
36 self
37 }
38
39 pub fn ignore_user_config(mut self, enable: bool) -> Self {
40 self.ignore_user_config = enable;
41 self
42 }
43
44 pub fn config_override(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
45 self.overrides
46 .config_overrides
47 .push(ConfigOverride::new(key, value));
48 self
49 }
50
51 pub fn config_override_raw(mut self, raw: impl Into<String>) -> Self {
52 self.overrides
53 .config_overrides
54 .push(ConfigOverride::from_raw(raw));
55 self
56 }
57
58 pub fn profile(mut self, profile: impl Into<String>) -> Self {
59 let profile = profile.into();
60 self.overrides.profile = (!profile.trim().is_empty()).then_some(profile);
61 self
62 }
63
64 pub fn oss(mut self, enable: bool) -> Self {
65 self.overrides.oss = if enable {
66 FlagState::Enable
67 } else {
68 FlagState::Disable
69 };
70 self
71 }
72
73 pub fn enable_feature(mut self, name: impl Into<String>) -> Self {
74 self.overrides.feature_toggles.enable.push(name.into());
75 self
76 }
77
78 pub fn disable_feature(mut self, name: impl Into<String>) -> Self {
79 self.overrides.feature_toggles.disable.push(name.into());
80 self
81 }
82
83 pub fn search(mut self, enable: bool) -> Self {
84 self.overrides.search = if enable {
85 FlagState::Enable
86 } else {
87 FlagState::Disable
88 };
89 self
90 }
91}