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