Rest/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
6/// root directory, and separator for file paths.
7pub struct Struct {
8	/// A vector of strings representing patterns to exclude.
9	pub Exclude:Vec<String>,
10
11	/// A flag indicating whether to execute commands in parallel.
12	pub Parallel:Parallel,
13
14	/// A string pattern to match against the last element of each entry.
15	pub Pattern:Pattern,
16
17	/// The root directory to start the walk from.
18	pub Root:String,
19
20	/// The separator used for file paths.
21	pub Separator:Separator,
22}
23
24impl Struct {
25	/// Creates a new instance of the Struct.
26	///
27	/// This function initializes the Struct with the provided options,
28
29	/// generating the exclude patterns, omit patterns, parallel flag, pattern,
30
31	/// root directory, and separator from the options.
32	///
33	/// # Argument
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
50			Parallel:Command().get_flag("Parallel"),
51
52			Pattern:Command().get_one::<String>("Pattern").expect("Cannot Pattern.").to_owned(),
53
54			Root:Command().get_one::<String>("Root").expect("Cannot Root.").to_owned(),
55
56			Separator,
57		}
58	}
59}
60
61use crate::{Fn::Binary::Command::Fn as Command, Struct::Binary::Command::Struct as Option};
62
63/// Type alias for a vector of strings representing command options.
64pub type Command = Vec<String>;
65
66/// Type alias for a boolean flag indicating parallel execution.
67pub type Parallel = bool;
68
69/// Type alias for a string pattern to match.
70pub type Pattern = String;
71
72/// Type alias for a character used as a separator for file paths.
73pub type Separator = char;