From 0afa8fcb4fc690a060b3b8649d6e3b7d06d8ba1e Mon Sep 17 00:00:00 2001 From: rhysd Date: Fri, 28 Jan 2022 21:50:14 +0900 Subject: [PATCH] cli: Add --version flag --- cli/src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cli/src/main.rs b/cli/src/main.rs index 9c43dc02b..062ea6d7f 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -64,6 +64,10 @@ struct Args { #[argh(option)] stdin_file_path: Option, + /// show version + #[argh(switch)] + version: bool, + /// the input and output files. /// /// First positional argument is the input file. If not specified, the @@ -209,6 +213,10 @@ fn run() -> Result<(), Box> { // Parse commandline arguments let args: Args = argh::from_env(); + if args.version { + println!("{}", env!("CARGO_PKG_VERSION")); + return Ok(()); + } let (input_path, input) = if let Some(path) = args.files.first() { let path = Path::new(path); (path, fs::read(path)?)