Library/Struct/Binary/Command/Option.rs
1/// Represents the options for binary command execution.
2///
3/// This struct holds various fields related to the command options, including exclude patterns,
4/// omit patterns, parallel execution flag, pattern to match, root directory, and separator for file paths.
5pub struct Struct {
6 /// A vector of strings representing patterns to exclude.
7 pub Exclude: Vec<String>,
8
9 /// A vector of strings representing patterns to omit.
10 pub Omit: Vec<String>,
11
12 /// A flag indicating whether to execute commands in parallel.
13 pub Parallel: Parallel,
14
15 /// A string pattern to match against the last element of each entry.
16 pub Pattern: Pattern,
17
18 /// The root directory to start the walk from.
19 pub Root: String,
20
21 /// The separator used for file paths.
22 pub Separator: Separator,
23}
24
25impl Struct {
26 /// Creates a new instance of the Struct.
27 ///
28 /// This function initializes the Struct with the provided options, generating the exclude patterns,
29 /// omit patterns, parallel flag, pattern, root directory, and separator from the options.
30 ///
31 /// # Arguments
32 ///
33 /// * `Option` - A reference to an Option struct containing initialization parameters.
34 ///
35 /// # Returns
36 ///
37 /// Returns a new instance of Struct.
38 pub fn Fn(Option { Separator, .. }: Option) -> Self {
39 Self {
40 Exclude: Command()
41 .get_one::<String>("Exclude")
42 .expect("Cannot Exclude.")
43 .split(" ")
44 .map(|Exclude| Exclude.to_string())
45 .collect::<Vec<_>>(),
46 Parallel: Command().get_flag("Parallel"),
47 Pattern: Command().get_one::<String>("Pattern").expect("Cannot Pattern.").to_owned(),
48 Root: Command().get_one::<String>("Root").expect("Cannot Root.").to_owned(),
49 Separator,
50 Omit: Command()
51 .get_many::<String>("Omit")
52 .expect("Cannot Omit.")
53 .map(|Omit| Omit.to_string())
54 .collect(),
55 }
56 }
57}
58
59use crate::{Fn::Binary::Command::Fn as Command, Struct::Binary::Command::Struct as Option};
60
61/// Type alias for a vector of strings representing command options.
62pub type Command = Vec<String>;
63
64/// Type alias for a boolean flag indicating parallel execution.
65pub type Parallel = bool;
66
67/// Type alias for a string pattern to match.
68pub type Pattern = String;
69
70/// Type alias for a character used as a separator for file paths.
71pub type Separator = char;
72
73/// Type alias for a vector of strings representing patterns to omit.
74pub type Omit = Vec<String>;