-
-
Notifications
You must be signed in to change notification settings - Fork 222
/
mod.rs
51 lines (46 loc) · 1.32 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use anyhow::Result;
use clap::{ArgMatches, Command};
pub mod bundle_sources;
pub mod check;
pub mod find;
pub mod print_sources;
pub mod upload;
macro_rules! each_subcommand {
($mac:ident) => {
$mac!(bundle_sources);
$mac!(check);
$mac!(find);
$mac!(print_sources);
$mac!(upload);
};
}
pub fn make_command(mut command: Command) -> Command {
macro_rules! add_subcommand {
($name:ident) => {{
command = command.subcommand(crate::commands::debug_files::$name::make_command(
Command::new(stringify!($name).replace('_', "-")),
));
}};
}
command = command
.about("Locate, analyze or upload debug information files.")
.subcommand_required(true)
.arg_required_else_help(true)
.visible_alias("dif")
.alias("difutil");
each_subcommand!(add_subcommand);
command
}
pub fn execute(matches: &ArgMatches) -> Result<()> {
macro_rules! execute_subcommand {
($name:ident) => {{
if let Some(sub_matches) =
matches.subcommand_matches(&stringify!($name).replace('_', "-"))
{
return crate::commands::debug_files::$name::execute(&sub_matches);
}
}};
}
each_subcommand!(execute_subcommand);
unreachable!();
}