From bc9bdf17b280a3b950459639ee6467f2f64ba8ea Mon Sep 17 00:00:00 2001 From: Dominik Niedbala Date: Wed, 18 Feb 2026 00:30:20 +0700 Subject: [PATCH] Fix broken CLI caused by double-parse bug from PR #408 The empty `Cli` struct added in PR #408 intercepts all argument parsing before the real `Args` struct is reached, making all subcommands and `--help` non-functional. Move the custom VERSION constant (with "v" prefix) into the shared `cb_cli` crate and remove the empty `Cli` structs from all three binaries (cli, pbs, signer). Fixes #375 --- bin/cli.rs | 14 -------------- bin/pbs.rs | 14 +------------- bin/signer.rs | 14 +------------- crates/cli/src/lib.rs | 25 ++++++++++++++++++++++--- 4 files changed, 24 insertions(+), 43 deletions(-) diff --git a/bin/cli.rs b/bin/cli.rs index 234dc9bd..5512b820 100644 --- a/bin/cli.rs +++ b/bin/cli.rs @@ -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(); diff --git a/bin/pbs.rs b/bin/pbs.rs index ca8d9c9c..01328e4c 100644 --- a/bin/pbs.rs +++ b/bin/pbs.rs @@ -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)?; diff --git a/bin/signer.rs b/bin/signer.rs index 01f3c970..e86acd60 100644 --- a/bin/signer.rs +++ b/bin/signer.rs @@ -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); diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 34170470..738285e1 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -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, @@ -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"); + } +}