#![doc(
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)]
#![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 reth_db::ClientVersion;
use std::{borrow::Cow, ffi::OsString};
pub mod chainspec;
use crate::chainspec::ChainSpecParser;
pub trait RethCli: Sized {
type ChainSpecParser: ChainSpecParser;
fn name(&self) -> Cow<'static, str>;
fn version(&self) -> Cow<'static, str>;
fn parse_args() -> Result<Self, Error>
where
Self: Parser,
{
<Self as RethCli>::try_parse_from(std::env::args_os())
}
fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
where
Self: Parser,
I: IntoIterator<Item = T>,
T: Into<OsString> + Clone,
{
<Self as Parser>::try_parse_from(itr)
}
fn with_runner<F, R>(self, f: F) -> R
where
F: FnOnce(Self, CliRunner) -> R,
{
let runner = CliRunner::default();
f(self, runner)
}
fn execute<F, R>(f: F) -> Result<R, Error>
where
Self: Parser,
F: FnOnce(Self, CliRunner) -> R,
{
let cli = Self::parse_args()?;
Ok(cli.with_runner(f))
}
fn client_version() -> ClientVersion;
}