From ab5c0717bd4eed4b56c01af0e8f27bbfac27ffe8 Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Sat, 13 Dec 2025 10:58:23 -0600 Subject: [PATCH 1/2] feat: display version at start of all CLI executions - Add version output to normal file processing (not just --version/--help) - Format: 'bbl_parser 0.9.0 ()' via vergen - Prints only when processing files (after help early exit) - No duplicate printing: --version/--help handled by clap separately - Resolves issue #29 --- src/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.rs b/src/main.rs index 0c12020..63ce1aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -329,6 +329,9 @@ fn main() -> Result<()> { } }; + // Print version at start of normal execution (only when processing files) + println!("{} {}", env!("CARGO_PKG_NAME"), VERSION_STR); + let export_options = ExportOptions { csv: true, // CSV export is always enabled for the CLI binary gpx: export_gpx, From 00e119bbfdb1be7e70cdea4889bd205c99331447 Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Sat, 13 Dec 2025 11:07:05 -0600 Subject: [PATCH 2/2] feat: display version at start of all CLI contexts with empty line - Print version before get_matches() for all contexts - Version shows for: -V, --version, --help, normal execution, no params - Format: 'bbl_parser ()' via vergen - Empty line separates version from help/output - Add custom -V/--version args with exclusive flag - Early exit if only --version/-V requested - Simple approach: print once at start, no duplication - Resolves issue #29 --- src/main.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 63ce1aa..02bf6c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -262,8 +262,15 @@ fn build_command() -> Command { "Read and parse BBL blackbox log files. Exports to CSV by default (optionally GPX/JSON)."; Command::new(env!("CARGO_PKG_NAME")) - .version(VERSION_STR) .about(about_text) + .arg( + Arg::new("version") + .short('V') + .long("version") + .help("Print version") + .action(clap::ArgAction::SetTrue) + .exclusive(true), + ) .arg( Arg::new("files") .help("BBL files or directories to parse. Direct file paths: .BBL, .BFL, .TXT extensions supported. Directories: recursively finds .BBL/.BFL files only (TXT files must be specified directly). Case-insensitive, supports globbing.") @@ -310,8 +317,17 @@ fn build_command() -> Command { } fn main() -> Result<()> { + // Print version at start of every execution context + println!("{} {}", env!("CARGO_PKG_NAME"), VERSION_STR); + println!(); + let matches = build_command().get_matches(); + // Exit if only --version/-V requested + if matches.get_flag("version") { + return Ok(()); + } + let debug = matches.get_flag("debug"); let export_gpx = matches.get_flag("gpx") || matches.get_flag("gps"); let export_event = matches.get_flag("event"); @@ -329,9 +345,6 @@ fn main() -> Result<()> { } }; - // Print version at start of normal execution (only when processing files) - println!("{} {}", env!("CARGO_PKG_NAME"), VERSION_STR); - let export_options = ExportOptions { csv: true, // CSV export is always enabled for the CLI binary gpx: export_gpx,