From 46fdc3883352127b60e91079322bb055df28f4ce Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 25 Jun 2024 13:49:27 +0200 Subject: [PATCH] feat: initial cli abstraction (#9082) --- Cargo.lock | 4 ++++ Cargo.toml | 2 ++ crates/cli/cli/Cargo.toml | 10 ++++++++++ crates/cli/cli/src/lib.rs | 25 +++++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 crates/cli/cli/Cargo.toml create mode 100644 crates/cli/cli/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 89f2eecd06..a92397fea4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6494,6 +6494,10 @@ dependencies = [ "serde_json", ] +[[package]] +name = "reth-cli" +version = "1.0.0" + [[package]] name = "reth-cli-commands" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 62770b9deb..24f3af5adf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ members = [ "crates/blockchain-tree/", "crates/blockchain-tree-api/", "crates/chainspec/", + "crates/cli/cli/", "crates/cli/commands/", "crates/cli/runner/", "crates/config/", @@ -258,6 +259,7 @@ reth-beacon-consensus = { path = "crates/consensus/beacon" } reth-blockchain-tree = { path = "crates/blockchain-tree" } reth-blockchain-tree-api = { path = "crates/blockchain-tree-api" } reth-chainspec = { path = "crates/chainspec" } +reth-cli = { path = "crates/cli/cli" } reth-cli-commands = { path = "crates/cli/commands" } reth-cli-runner = { path = "crates/cli/runner" } reth-codecs = { path = "crates/storage/codecs" } diff --git a/crates/cli/cli/Cargo.toml b/crates/cli/cli/Cargo.toml new file mode 100644 index 0000000000..3487782c9e --- /dev/null +++ b/crates/cli/cli/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "reth-cli" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[lints] diff --git a/crates/cli/cli/src/lib.rs b/crates/cli/cli/src/lib.rs new file mode 100644 index 0000000000..513380fdd0 --- /dev/null +++ b/crates/cli/cli/src/lib.rs @@ -0,0 +1,25 @@ +//! Cli abstraction for reth based nodes. + +#![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 std::borrow::Cow; + +/// Reth based node cli. +/// +/// This trait is supposed to be implemented by the main struct of the CLI. +/// +/// It provides commonly used functionality for running commands and information about the CL, such +/// as the name and version. +pub trait RethCli: Sized { + /// The name of the implementation, eg. `reth`, `op-reth`, etc. + fn name(&self) -> Cow<'static, str>; + + /// The version of the node, such as `reth/v1.0.0` + fn version(&self) -> Cow<'static, str>; +}