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