Skip to content

Commit 820ad97

Browse files
authored
fix/feat: display version at start of all CLI contexts with empty line (#30)
* 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 <git_sha> (<date>)' via vergen - Prints only when processing files (after help early exit) - No duplicate printing: --version/--help handled by clap separately - Resolves issue #29 * 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 <semver> <sha> (<date>)' 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
1 parent 416808b commit 820ad97

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/main.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,15 @@ fn build_command() -> Command {
262262
"Read and parse BBL blackbox log files. Exports to CSV by default (optionally GPX/JSON).";
263263

264264
Command::new(env!("CARGO_PKG_NAME"))
265-
.version(VERSION_STR)
266265
.about(about_text)
266+
.arg(
267+
Arg::new("version")
268+
.short('V')
269+
.long("version")
270+
.help("Print version")
271+
.action(clap::ArgAction::SetTrue)
272+
.exclusive(true),
273+
)
267274
.arg(
268275
Arg::new("files")
269276
.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 {
310317
}
311318

312319
fn main() -> Result<()> {
320+
// Print version at start of every execution context
321+
println!("{} {}", env!("CARGO_PKG_NAME"), VERSION_STR);
322+
println!();
323+
313324
let matches = build_command().get_matches();
314325

326+
// Exit if only --version/-V requested
327+
if matches.get_flag("version") {
328+
return Ok(());
329+
}
330+
315331
let debug = matches.get_flag("debug");
316332
let export_gpx = matches.get_flag("gpx") || matches.get_flag("gps");
317333
let export_event = matches.get_flag("event");

0 commit comments

Comments
 (0)