@@ -5,8 +5,11 @@ use clap::{Parser, Subcommand};
55
66mod docker_init;
77
8+ /// Version string with a leading 'v'
9+ const VERSION : & str = concat ! ( "v" , env!( "CARGO_PKG_VERSION" ) ) ;
10+
811#[ derive( Parser , Debug ) ]
9- #[ command( version, about, long_about = LONG_ABOUT , name = "commit-boost-cli" ) ]
12+ #[ command( version = VERSION , about, long_about = LONG_ABOUT , name = "commit-boost-cli" ) ]
1013pub struct Args {
1114 #[ command( subcommand) ]
1215 pub cmd : Command ,
@@ -41,9 +44,25 @@ impl Args {
4144const LONG_ABOUT : & str = "Commit-Boost allows Ethereum validators to safely run MEV-Boost and community-built commitment protocols" ;
4245
4346#[ derive( Parser , Debug ) ]
44- #[ command( version, about, long_about = LONG_ABOUT , name = "commit-boost-pbs" ) ]
47+ #[ command( version = VERSION , about, long_about = LONG_ABOUT , name = "commit-boost-pbs" ) ]
4548pub struct PbsArgs ;
4649
4750#[ derive( Parser , Debug ) ]
48- #[ command( version, about, long_about = LONG_ABOUT , name = "commit-boost-signer" ) ]
51+ #[ command( version = VERSION , about, long_about = LONG_ABOUT , name = "commit-boost-signer" ) ]
4952pub struct SignerArgs ;
53+
54+ #[ cfg( test) ]
55+ mod tests {
56+ use super :: * ;
57+
58+ #[ test]
59+ fn version_has_v_prefix ( ) {
60+ assert ! ( VERSION . starts_with( 'v' ) , "VERSION should start with 'v', got: {VERSION}" ) ;
61+ }
62+
63+ #[ test]
64+ fn parse_init_subcommand ( ) {
65+ Args :: try_parse_from ( [ "commit-boost-cli" , "init" , "--config" , "/tmp/config.toml" ] )
66+ . expect ( "should parse init subcommand" ) ;
67+ }
68+ }
0 commit comments