[][src]Macro sc_cli::substrate_cli_subcommands

macro_rules! substrate_cli_subcommands {
    ($enum:ident => $($variant:ident),*) => { ... };
}

Macro that helps implement CliConfiguration on an enum of subcommand automatically

Example




enum Subcommand {
    Variant1(EmptyVariant),
    Variant2(EmptyVariant),
}

substrate_cli_subcommands!(
    Subcommand => Variant1, Variant2
);

Which will expand to:

This example is not tested
impl CliConfiguration for Subcommand {
    fn base_path(&self) -> Result<Option<PathBuf>> {
        match self {
            Subcommand::Variant1(cmd) => cmd.base_path(),
            Subcommand::Variant2(cmd) => cmd.base_path(),
        }
    }

    fn is_dev(&self) -> Result<bool> {
        match self {
            Subcommand::Variant1(cmd) => cmd.is_dev(),
            Subcommand::Variant2(cmd) => cmd.is_dev(),
        }
    }

    // ...
}