darklua_core/frontend/
options.rs1use std::path::{Path, PathBuf};
2
3use super::configuration::{Configuration, GeneratorParameters};
4
5#[derive(Debug)]
6pub struct Options {
7 input: PathBuf,
8 config_path: Option<PathBuf>,
9 config: Option<Configuration>,
10 config_generator_override: Option<GeneratorParameters>,
11 output: Option<PathBuf>,
12 fail_fast: bool,
13}
14
15impl Options {
16 pub fn new(input: impl Into<PathBuf>) -> Self {
17 Self {
18 input: input.into(),
19 config_path: None,
20 config: None,
21 output: None,
22 fail_fast: false,
23 config_generator_override: None,
24 }
25 }
26
27 pub fn with_configuration_at(mut self, config: impl Into<PathBuf>) -> Self {
28 self.config_path = Some(config.into());
29 self
30 }
31
32 pub fn with_configuration(mut self, config: Configuration) -> Self {
33 self.config = Some(config);
34 self
35 }
36
37 pub fn with_output(mut self, output: impl Into<PathBuf>) -> Self {
38 self.output = Some(output.into());
39 self
40 }
41
42 pub fn fail_fast(mut self) -> Self {
43 self.fail_fast = true;
44 self
45 }
46
47 pub fn with_generator_override(mut self, generator: impl Into<GeneratorParameters>) -> Self {
48 self.config_generator_override = Some(generator.into());
49 self
50 }
51
52 pub fn input(&self) -> &Path {
53 &self.input
54 }
55
56 pub fn output(&self) -> Option<&Path> {
57 self.output.as_ref().map(AsRef::as_ref)
58 }
59
60 pub fn should_fail_fast(&self) -> bool {
61 self.fail_fast
62 }
63
64 pub fn configuration_path(&self) -> Option<&Path> {
65 self.config_path.as_ref().map(AsRef::as_ref)
66 }
67
68 pub fn generator_override(&self) -> Option<&GeneratorParameters> {
69 self.config_generator_override.as_ref()
70 }
71
72 pub fn take_configuration(&mut self) -> Option<Configuration> {
73 self.config.take()
74 }
75}