1#![doc(
4 html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
5 html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
6 issue_tracker_base_url = "https://github.com/SeismicSystems/seismic-reth/issues/"
7)]
8#![cfg_attr(not(test), warn(unused_crate_dependencies))]
9#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
10
11use clap::{Error, Parser};
12use reth_cli_runner::CliRunner;
13use reth_db::ClientVersion;
14use std::{borrow::Cow, ffi::OsString};
15
16pub mod chainspec;
18use crate::chainspec::ChainSpecParser;
19
20pub trait RethCli: Sized {
27 type ChainSpecParser: ChainSpecParser;
29
30 fn name(&self) -> Cow<'static, str>;
32
33 fn version(&self) -> Cow<'static, str>;
35
36 fn parse_args() -> Result<Self, Error>
38 where
39 Self: Parser,
40 {
41 <Self as RethCli>::try_parse_from(std::env::args_os())
42 }
43
44 fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
46 where
47 Self: Parser,
48 I: IntoIterator<Item = T>,
49 T: Into<OsString> + Clone,
50 {
51 <Self as Parser>::try_parse_from(itr)
52 }
53
54 fn with_runner<F, R>(self, f: F) -> R
56 where
57 F: FnOnce(Self, CliRunner) -> R,
58 {
59 let runner = CliRunner::default();
60
61 f(self, runner)
62 }
63
64 fn execute<F, R>(f: F) -> Result<R, Error>
66 where
67 Self: Parser,
68 F: FnOnce(Self, CliRunner) -> R,
69 {
70 let cli = Self::parse_args()?;
71
72 Ok(cli.with_runner(f))
73 }
74
75 fn client_version() -> ClientVersion;
77}