git_rune/config/
builder.rs1use super::types::Config;
2
3#[derive(Default)]
4pub struct ConfigBuilder {
5 api_base: Option<String>,
6 api_key: Option<String>,
7 model: Option<String>,
8 path: Option<String>,
9 include: Option<String>,
10 exclude: Option<String>,
11}
12
13impl ConfigBuilder {
14 pub fn new() -> Self {
15 Self::default()
16 }
17
18 pub fn api_base<S: Into<String>>(mut self, api_base: S) -> Self {
19 self.api_base = Some(api_base.into());
20 self
21 }
22
23 pub fn api_key<S: Into<String>>(mut self, api_key: S) -> Self {
24 self.api_key = Some(api_key.into());
25 self
26 }
27
28 pub fn model<S: Into<String>>(mut self, model: S) -> Self {
29 self.model = Some(model.into());
30 self
31 }
32
33 pub fn path<S: Into<String>>(mut self, path: S) -> Self {
34 self.path = Some(path.into());
35 self
36 }
37
38 pub fn include<S: Into<String>>(mut self, include: S) -> Self {
39 self.include = Some(include.into());
40 self
41 }
42
43 pub fn exclude<S: Into<String>>(mut self, exclude: S) -> Self {
44 self.exclude = Some(exclude.into());
45 self
46 }
47
48 pub fn build(self) -> Config {
49 let mut config = Config::default();
50
51 if let Some(api_base) = self.api_base {
52 config.llm.api_base = Some(api_base);
53 }
54 if let Some(api_key) = self.api_key {
55 config.llm.api_key = Some(api_key);
56 }
57 if let Some(model) = self.model {
58 config.llm.model = model;
59 }
60 if let Some(path) = self.path {
61 config.parse.path = path;
62 }
63 if let Some(include) = self.include {
64 config.parse.include = Some(include);
65 }
66 if let Some(exclude) = self.exclude {
67 config.parse.exclude = Some(exclude);
68 }
69
70 config
71 }
72}