-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(dre): replacing boiler plate enum calls with a procedural ma…
…cro (#702)
- Loading branch information
1 parent
6c934f8
commit 4aec5fc
Showing
12 changed files
with
138 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,27 @@ | ||
use clap::{Args, Subcommand}; | ||
use clap::Args; | ||
use remove::Remove; | ||
|
||
use super::{ExecutableCommand, IcAdminRequirement}; | ||
use super::{impl_executable_command_for_enums, ExecutableCommand, IcAdminRequirement}; | ||
|
||
mod remove; | ||
|
||
#[derive(Args, Debug)] | ||
pub struct Nodes { | ||
#[clap(subcommand)] | ||
pub subcommand: NodesSubcommands, | ||
} | ||
|
||
#[derive(Subcommand, Debug)] | ||
pub enum NodesSubcommands { | ||
/// Remove nodes from the network | ||
Remove(Remove), | ||
pub subcommand: Subcommands, | ||
} | ||
impl_executable_command_for_enums! { Remove } | ||
|
||
impl ExecutableCommand for Nodes { | ||
fn require_ic_admin(&self) -> IcAdminRequirement { | ||
match &self.subcommand { | ||
NodesSubcommands::Remove(r) => r.require_ic_admin(), | ||
} | ||
self.subcommand.require_ic_admin() | ||
} | ||
|
||
async fn execute(&self, ctx: crate::ctx::DreContext) -> anyhow::Result<()> { | ||
match &self.subcommand { | ||
NodesSubcommands::Remove(r) => r.execute(ctx).await, | ||
} | ||
self.subcommand.execute(ctx).await | ||
} | ||
|
||
fn validate(&self, cmd: &mut clap::Command) { | ||
match &self.subcommand { | ||
NodesSubcommands::Remove(r) => r.validate(cmd), | ||
} | ||
self.subcommand.validate(cmd) | ||
} | ||
} |
Oops, something went wrong.