1use std::path::PathBuf;
2
3use crate::CliOverridesPatch;
4
5#[derive(Clone, Debug, Eq, PartialEq)]
7pub struct ReviewCommandRequest {
8 pub prompt: Option<String>,
9 pub base: Option<String>,
10 pub commit: Option<String>,
11 pub title: Option<String>,
12 pub uncommitted: bool,
13 pub overrides: CliOverridesPatch,
15}
16
17impl ReviewCommandRequest {
18 pub fn new() -> Self {
19 Self {
20 prompt: None,
21 base: None,
22 commit: None,
23 title: None,
24 uncommitted: false,
25 overrides: CliOverridesPatch::default(),
26 }
27 }
28
29 pub fn prompt(mut self, prompt: impl Into<String>) -> Self {
30 let prompt = prompt.into();
31 self.prompt = (!prompt.trim().is_empty()).then_some(prompt);
32 self
33 }
34
35 pub fn base(mut self, branch: impl Into<String>) -> Self {
36 let branch = branch.into();
37 self.base = (!branch.trim().is_empty()).then_some(branch);
38 self
39 }
40
41 pub fn commit(mut self, sha: impl Into<String>) -> Self {
42 let sha = sha.into();
43 self.commit = (!sha.trim().is_empty()).then_some(sha);
44 self
45 }
46
47 pub fn title(mut self, title: impl Into<String>) -> Self {
48 let title = title.into();
49 self.title = (!title.trim().is_empty()).then_some(title);
50 self
51 }
52
53 pub fn uncommitted(mut self, enable: bool) -> Self {
54 self.uncommitted = enable;
55 self
56 }
57
58 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
59 self.overrides = overrides;
60 self
61 }
62}
63
64impl Default for ReviewCommandRequest {
65 fn default() -> Self {
66 Self::new()
67 }
68}
69
70#[derive(Clone, Debug, Eq, PartialEq)]
72pub struct ExecReviewCommandRequest {
73 pub prompt: Option<String>,
74 pub base: Option<String>,
75 pub commit: Option<String>,
76 pub title: Option<String>,
77 pub uncommitted: bool,
78 pub ephemeral: bool,
79 pub ignore_rules: bool,
80 pub ignore_user_config: bool,
81 pub json: bool,
82 pub output_last_message: Option<PathBuf>,
83 pub skip_git_repo_check: bool,
84 pub overrides: CliOverridesPatch,
86}
87
88impl ExecReviewCommandRequest {
89 pub fn new() -> Self {
90 Self {
91 prompt: None,
92 base: None,
93 commit: None,
94 title: None,
95 uncommitted: false,
96 ephemeral: false,
97 ignore_rules: false,
98 ignore_user_config: false,
99 json: false,
100 output_last_message: None,
101 skip_git_repo_check: true,
102 overrides: CliOverridesPatch::default(),
103 }
104 }
105
106 pub fn prompt(mut self, prompt: impl Into<String>) -> Self {
107 let prompt = prompt.into();
108 self.prompt = (!prompt.trim().is_empty()).then_some(prompt);
109 self
110 }
111
112 pub fn base(mut self, branch: impl Into<String>) -> Self {
113 let branch = branch.into();
114 self.base = (!branch.trim().is_empty()).then_some(branch);
115 self
116 }
117
118 pub fn commit(mut self, sha: impl Into<String>) -> Self {
119 let sha = sha.into();
120 self.commit = (!sha.trim().is_empty()).then_some(sha);
121 self
122 }
123
124 pub fn title(mut self, title: impl Into<String>) -> Self {
125 let title = title.into();
126 self.title = (!title.trim().is_empty()).then_some(title);
127 self
128 }
129
130 pub fn uncommitted(mut self, enable: bool) -> Self {
131 self.uncommitted = enable;
132 self
133 }
134
135 pub fn ephemeral(mut self, enable: bool) -> Self {
136 self.ephemeral = enable;
137 self
138 }
139
140 pub fn ignore_rules(mut self, enable: bool) -> Self {
141 self.ignore_rules = enable;
142 self
143 }
144
145 pub fn ignore_user_config(mut self, enable: bool) -> Self {
146 self.ignore_user_config = enable;
147 self
148 }
149
150 pub fn json(mut self, enable: bool) -> Self {
151 self.json = enable;
152 self
153 }
154
155 pub fn output_last_message(mut self, path: impl Into<PathBuf>) -> Self {
156 self.output_last_message = Some(path.into());
157 self
158 }
159
160 pub fn skip_git_repo_check(mut self, enable: bool) -> Self {
161 self.skip_git_repo_check = enable;
162 self
163 }
164
165 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
166 self.overrides = overrides;
167 self
168 }
169}
170
171impl Default for ExecReviewCommandRequest {
172 fn default() -> Self {
173 Self::new()
174 }
175}