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