clap_utils/
macros.rs

1/// define a new subcommand
2#[macro_export]
3macro_rules! subcmd {
4    ($name:ident, [$($variant:ident=$comment:expr),*]) => {
5        $crate::paste! {
6            #[derive(clap::Subcommand, Debug, Clone)]
7            #[enum_dispatch]
8            #[non_exhaustive]
9            pub enum $name {
10                $(
11                    #[doc=$comment]
12                    $variant([<$name $variant Command>]),
13                )*
14            }
15        }
16    };
17}
18
19/// define and pub use the mod
20#[macro_export]
21macro_rules! mod_pub_use {
22    ($($name:ident),*) => {
23        $(
24            mod $name;
25            pub use $name::*;
26        )*
27    };
28}
29
30#[macro_export]
31macro_rules! error_report {
32    ($s:literal) => {
33        Err($crate::anyhow::anyhow!($s)).report()
34    };
35    ($fmt:expr, $($arg:tt)*) => {
36        Err($crate::anyhow::anyhow!($fmt, $($arg)*)).report()
37    };
38}