mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: parsers (#9366)
This commit is contained in:
@ -8,13 +8,17 @@ homepage.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-cli-runner.workspace = true
|
||||
reth-chainspec.workspace = true
|
||||
eyre.workspace = true
|
||||
|
||||
# misc
|
||||
clap.workspace = true
|
||||
eyre.workspace = true
|
||||
|
||||
|
||||
|
||||
|
||||
@ -21,5 +21,5 @@ pub trait ChainSpecParser: TypedValueParser<Value = Arc<ChainSpec>> + Default {
|
||||
///
|
||||
/// This function will return an error if the input string cannot be parsed into a valid
|
||||
/// [`ChainSpec`].
|
||||
fn parse(&self, s: &str) -> eyre::Result<Arc<ChainSpec>>;
|
||||
fn parse(s: &str) -> eyre::Result<Arc<ChainSpec>>;
|
||||
}
|
||||
|
||||
@ -8,12 +8,11 @@
|
||||
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
|
||||
use clap::{Error, Parser};
|
||||
use reth_cli_runner::CliRunner;
|
||||
use std::{borrow::Cow, ffi::OsString};
|
||||
|
||||
use reth_cli_runner::CliRunner;
|
||||
|
||||
use clap::{Error, Parser};
|
||||
|
||||
/// The chainspec module defines the different chainspecs that can be used by the node.
|
||||
pub mod chainspec;
|
||||
|
||||
/// Reth based node cli.
|
||||
@ -32,7 +31,7 @@ pub trait RethCli: Sized {
|
||||
/// Parse args from iterator from [`std::env::args_os()`].
|
||||
fn parse_args() -> Result<Self, Error>
|
||||
where
|
||||
Self: Parser + Sized,
|
||||
Self: Parser,
|
||||
{
|
||||
<Self as RethCli>::try_parse_from(std::env::args_os())
|
||||
}
|
||||
@ -40,7 +39,7 @@ pub trait RethCli: Sized {
|
||||
/// Parse args from the given iterator.
|
||||
fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
|
||||
where
|
||||
Self: Parser + Sized,
|
||||
Self: Parser,
|
||||
I: IntoIterator<Item = T>,
|
||||
T: Into<OsString> + Clone,
|
||||
{
|
||||
@ -60,7 +59,7 @@ pub trait RethCli: Sized {
|
||||
/// Parses and executes a command.
|
||||
fn execute<F, R>(f: F) -> Result<R, Error>
|
||||
where
|
||||
Self: Parser + Sized,
|
||||
Self: Parser,
|
||||
F: FnOnce(Self, CliRunner) -> R,
|
||||
{
|
||||
let cli = Self::parse_args()?;
|
||||
|
||||
Reference in New Issue
Block a user