Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions bin/cli.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
use clap::Parser;

/// Version string with a leading 'v'
const VERSION: &str = concat!("v", env!("CARGO_PKG_VERSION"));

/// Subcommands and global arguments for the module
#[derive(Parser, Debug)]
#[command(name = "Commit-Boost CLI", version = VERSION, about, long_about = None)]
struct Cli {}

/// Main entry point of the Commit-Boost CLI
#[tokio::main]
async fn main() -> eyre::Result<()> {
// Parse the CLI arguments (currently only used for version info, more can be
// added later)
let _cli = Cli::parse();

color_eyre::install()?;
// set default backtrace unless provided

let args = cb_cli::Args::parse();

Expand Down
14 changes: 1 addition & 13 deletions bin/pbs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,14 @@ use clap::Parser;
use eyre::Result;
use tracing::{error, info};

/// Version string with a leading 'v'
const VERSION: &str = concat!("v", env!("CARGO_PKG_VERSION"));

/// Subcommands and global arguments for the module
#[derive(Parser, Debug)]
#[command(name = "Commit-Boost PBS Service", version = VERSION, about, long_about = None)]
struct Cli {}

#[tokio::main]
async fn main() -> Result<()> {
// Parse the CLI arguments (currently only used for version info, more can be
// added later)
let _cli = Cli::parse();
let _args = cb_cli::PbsArgs::parse();

color_eyre::install()?;

let _guard = initialize_tracing_log(PBS_MODULE_NAME, LogsSettings::from_env_config()?);

let _args = cb_cli::PbsArgs::parse();

let (pbs_config, config_path) = load_pbs_config(None).await?;

PbsService::init_metrics(pbs_config.chain)?;
Expand Down
14 changes: 1 addition & 13 deletions bin/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,14 @@ use clap::Parser;
use eyre::Result;
use tracing::{error, info};

/// Version string with a leading 'v'
const VERSION: &str = concat!("v", env!("CARGO_PKG_VERSION"));

/// Subcommands and global arguments for the module
#[derive(Parser, Debug)]
#[command(name = "Commit-Boost Signer Service", version = VERSION, about, long_about = None)]
struct Cli {}

#[tokio::main]
async fn main() -> Result<()> {
// Parse the CLI arguments (currently only used for version info, more can be
// added later)
let _cli = Cli::parse();
let _args = cb_cli::SignerArgs::parse();

color_eyre::install()?;

let _guard = initialize_tracing_log(SIGNER_MODULE_NAME, LogsSettings::from_env_config()?);

let _args = cb_cli::SignerArgs::parse();

let config = StartSignerConfig::load_from_env()?;
let server = SigningService::run(config);

Expand Down
25 changes: 22 additions & 3 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ use clap::{Parser, Subcommand};

mod docker_init;

/// Version string with a leading 'v'
const VERSION: &str = concat!("v", env!("CARGO_PKG_VERSION"));

#[derive(Parser, Debug)]
#[command(version, about, long_about = LONG_ABOUT, name = "commit-boost-cli")]
#[command(version = VERSION, about, long_about = LONG_ABOUT, name = "commit-boost-cli")]
pub struct Args {
#[command(subcommand)]
pub cmd: Command,
Expand Down Expand Up @@ -41,9 +44,25 @@ impl Args {
const LONG_ABOUT: &str = "Commit-Boost allows Ethereum validators to safely run MEV-Boost and community-built commitment protocols";

#[derive(Parser, Debug)]
#[command(version, about, long_about = LONG_ABOUT, name = "commit-boost-pbs")]
#[command(version = VERSION, about, long_about = LONG_ABOUT, name = "commit-boost-pbs")]
pub struct PbsArgs;

#[derive(Parser, Debug)]
#[command(version, about, long_about = LONG_ABOUT, name = "commit-boost-signer")]
#[command(version = VERSION, about, long_about = LONG_ABOUT, name = "commit-boost-signer")]
pub struct SignerArgs;

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn version_has_v_prefix() {
assert!(VERSION.starts_with('v'), "VERSION should start with 'v', got: {VERSION}");
}

#[test]
fn parse_init_subcommand() {
Args::try_parse_from(["commit-boost-cli", "init", "--config", "/tmp/config.toml"])
.expect("should parse init subcommand");
}
}