Skip to main content

Library/Fn/Binary/
Command.rs

1/// Creates and returns the command-line argument matches for the `Summary`
2/// application.
3///
4/// This function sets up the command-line interface using the `clap` crate,
5/// defining various arguments and their properties such as short and long
6/// names, help messages, default values, and whether they are required.
7///
8/// # Returns
9///
10/// Returns an `ArgMatches` instance containing the parsed command-line
11/// arguments.
12///
13/// # Arguments
14///
15/// * `Exclude` - An optional argument to specify patterns to exclude. Default
16///   is "node_modules".
17/// * `Omit` - An optional argument to specify patterns to omit. Default values
18///   are:
19///   - "(?i)documentation"
20///   - "(?i)target"
21///   - "(?i)changelog\.md$"
22///   - "(?i)summary\.md$"
23/// * `Parallel` - An optional flag to enable parallel processing.
24/// * `Pattern` - An optional argument to specify a pattern to match. Default is
25///   ".git".
26/// * `Root` - An optional argument to specify the root directory. Default is
27///   ".".
28///
29/// # Example
30///
31/// ```rust
32/// let matches = Fn();
33/// let exclude = matches.value_of("Exclude").unwrap_or("node_modules");
34/// let omit = matches.values_of("Omit").unwrap_or_default().collect::<Vec<_>>();
35/// let parallel = matches.is_present("Parallel");
36/// let pattern = matches.value_of("Pattern").unwrap_or(".git");
37/// let root = matches.value_of("Root").unwrap_or(".");
38/// ```
39///
40/// # Errors
41///
42/// This function will panic if there are issues with the argument definitions
43/// or parsing.
44pub fn Fn() -> ArgMatches {
45	Command::new("Summary")
46		.version(env!("CARGO_PKG_VERSION"))
47		.author("Source ✍🏻 Open 👐🏻 <Source/Open@PlayForm.Cloud>")
48		.about("Summary 🗣️")
49		.arg(
50			Arg::new("Exclude")
51				.short('E')
52				.long("Exclude")
53				.display_order(4)
54				.value_name("EXCLUDE")
55				.required(false)
56				.help("Exclude 🚫")
57				.default_value("node_modules"),
58		)
59		.arg(
60			Arg::new("Omit")
61				.short('O')
62				.long("Omit")
63				.display_order(6)
64				.value_name("OMIT")
65				.required(false)
66				.help("Omit 🚫")
67				.action(clap::ArgAction::Append)
68				.default_values(["(?i)documentation", "(?i)target", r"(?i)changelog\.md$", r"(?i)summary\.md$"]),
69		)
70		.arg(
71			Arg::new("Parallel")
72				.short('P')
73				.long("Parallel")
74				.action(SetTrue)
75				.display_order(2)
76				.value_name("PARALLEL")
77				.required(false)
78				.help("Parallel ⏩"),
79		)
80		.arg(
81			Arg::new("Pattern")
82				.long("Pattern")
83				.display_order(5)
84				.value_name("PATTERN")
85				.required(false)
86				.help("Pattern 🔍")
87				.default_value(".git"),
88		)
89		.arg(
90			Arg::new("Root")
91				.short('R')
92				.long("Root")
93				.display_order(3)
94				.value_name("ROOT")
95				.required(false)
96				.help("Root 📂")
97				.default_value("."),
98		)
99		.get_matches()
100}
101
102use clap::{Arg, ArgAction::SetTrue, ArgMatches, Command};
103
104pub mod Entry;
105pub mod Parallel;
106pub mod Sequential;