From 525aa0294bfe71b8b48859a8c0b2128de04f6592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=A4dorf?= Date: Wed, 18 Nov 2020 19:38:51 +0100 Subject: [PATCH] Fix verbose option --- Cargo.lock | 2 +- src/main.rs | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index feb714b..2748303 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,5 +2,5 @@ # It is not intended for manual editing. [[package]] name = "wlstreamer" -version = "0.1.0" +version = "0.2.0" diff --git a/src/main.rs b/src/main.rs index fa06eca..2e73d57 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,8 @@ struct Config { verbose: bool, } +const VERSION: &'static str = env!("CARGO_PKG_VERSION"); + fn help() { println!("Wrapper around wf-recorder and ffmpeg that automatically switches the screen being recorded based on current window focus"); println!(""); @@ -19,7 +21,8 @@ fn help() { println!(" --not-ws Do not show this workspace. Can be used multiple times. Example: 3"); println!(" --not-screen Do not show this screen. Can be used multiple times. Example: HDMI-A-1"); println!(" -o|--output Output to this device. Defaults to /dev/video0"); - println!(" -v|--verbose Verbose logging"); + println!(" -v|--version Display version and exit"); + println!(" --verbose Verbose logging"); println!(""); println!( "If there are no screens available for streaming, a black screen will be shown instead." @@ -62,7 +65,7 @@ fn record_screen(config: &mut Config, valid_screens: &Vec) -> Result) -> Result Result<(), Box> { } else if arg == "-o" || arg == "--output" { i += 1; config.output = args[i].clone(); - } else if arg == "-v" || arg == "--verbose" { + } else if arg == "--verbose" { config.verbose = true; + } else if arg == "-v" || arg == "--version" { + println!("v{}", VERSION); + std::process::exit(0); } else if arg == "-h" || arg == "--help" { help(); } else {