From ae3d48a6a751d14191aad4d54fde825b422059f9 Mon Sep 17 00:00:00 2001 From: gennyble Date: Sun, 15 Oct 2023 19:50:06 -0500 Subject: add -V/--version handling --- squash/src/cli.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/squash/src/cli.rs b/squash/src/cli.rs index ebc6b5b..80b3371 100644 --- a/squash/src/cli.rs +++ b/squash/src/cli.rs @@ -80,9 +80,12 @@ pub fn build() -> Cli { for arg in std::env::args().skip(1) { // Handle the special cases we want to obey. // -h/--help are standards and, even though we're playing with a - // dd-style syntax, we want to respect these + // dd-style syntax, we want to respect these. + // we'll do -V/--version if arg == "-h" || arg == "--help" { print_help() + } else if arg == "-V" || arg == "--version" { + print_version() } match arg.split_once('=') { @@ -155,3 +158,12 @@ fn print_help() -> ! { println!(" print this message and exit"); std::process::exit(0) } + +fn print_version() -> ! { + let version = env!("CARGO_PKG_VERSION"); + let authors = env!("CARGO_PKG_AUTHORS"); + + println!("squash version {version}"); + println!("written by {authors}"); + std::process::exit(0) +} -- cgit 1.4.1-3-g733a5