mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: add cli ext event hooks example (#4935)
This commit is contained in:
@ -113,6 +113,15 @@ impl<Ext: RethCliExt> Cli<Ext> {
|
||||
reth_tracing::init(layers);
|
||||
Ok(guard.flatten())
|
||||
}
|
||||
|
||||
/// Configures the given node extension.
|
||||
pub fn with_node_extension<C>(mut self, conf: C) -> Self
|
||||
where
|
||||
C: Into<Ext::Node>,
|
||||
{
|
||||
self.command.set_node_extension(conf.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Convenience function for parsing CLI options, set up logging and run the chosen command.
|
||||
@ -156,6 +165,17 @@ pub enum Commands<Ext: RethCliExt = ()> {
|
||||
Recover(recover::Command),
|
||||
}
|
||||
|
||||
impl<Ext: RethCliExt> Commands<Ext> {
|
||||
/// Sets the node extension if it is the [NodeCommand](node::NodeCommand).
|
||||
///
|
||||
/// This is a noop if the command is not the [NodeCommand](node::NodeCommand).
|
||||
pub fn set_node_extension(&mut self, ext: Ext::Node) {
|
||||
if let Commands::Node(command) = self {
|
||||
command.ext = ext
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The log configuration.
|
||||
#[derive(Debug, Args)]
|
||||
#[command(next_help_heading = "Logging")]
|
||||
|
||||
Reference in New Issue
Block a user