about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2023-10-15 19:50:06 -0500
committergennyble <gen@nyble.dev>2023-10-15 19:50:06 -0500
commitae3d48a6a751d14191aad4d54fde825b422059f9 (patch)
treedbb9388b852c00bf6dcd63a8cda0de66178e6e20
parent480c8baaa961f5b5ca0edafd55b595964cb1b395 (diff)
downloadcolorsquash-ae3d48a6a751d14191aad4d54fde825b422059f9.tar.gz
colorsquash-ae3d48a6a751d14191aad4d54fde825b422059f9.zip
add -V/--version handling
-rw-r--r--squash/src/cli.rs14
1 files changed, 13 insertions, 1 deletions
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)
+}