Fix verbose option
This commit is contained in:
parent
6eb5d01d47
commit
525aa0294b
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2,5 +2,5 @@
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wlstreamer"
|
name = "wlstreamer"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
|
|
||||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -10,6 +10,8 @@ struct Config {
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
fn help() {
|
fn help() {
|
||||||
println!("Wrapper around wf-recorder and ffmpeg that automatically switches the screen being recorded based on current window focus");
|
println!("Wrapper around wf-recorder and ffmpeg that automatically switches the screen being recorded based on current window focus");
|
||||||
println!("");
|
println!("");
|
||||||
|
@ -19,7 +21,8 @@ fn help() {
|
||||||
println!(" --not-ws <ws-num> Do not show this workspace. Can be used multiple times. Example: 3");
|
println!(" --not-ws <ws-num> Do not show this workspace. Can be used multiple times. Example: 3");
|
||||||
println!(" --not-screen <screen> Do not show this screen. Can be used multiple times. Example: HDMI-A-1");
|
println!(" --not-screen <screen> Do not show this screen. Can be used multiple times. Example: HDMI-A-1");
|
||||||
println!(" -o|--output <output> Output to this device. Defaults to /dev/video0");
|
println!(" -o|--output <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!("");
|
||||||
println!(
|
println!(
|
||||||
"If there are no screens available for streaming, a black screen will be shown instead."
|
"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<String>) -> Result<Chi
|
||||||
} else {
|
} else {
|
||||||
let index = get_screen_index(&valid_screens[0]);
|
let index = get_screen_index(&valid_screens[0]);
|
||||||
let output_str = format!("--file={}", config.output.as_str());
|
let output_str = format!("--file={}", config.output.as_str());
|
||||||
println!("Outputting to {}", output_str);
|
println!("Outputting to {}", config.output.as_str());
|
||||||
let mut cmd = Command::new("wf-recorder")
|
let mut cmd = Command::new("wf-recorder")
|
||||||
.args(&[
|
.args(&[
|
||||||
"--muxer=v4l2",
|
"--muxer=v4l2",
|
||||||
|
@ -72,14 +75,14 @@ fn record_screen(config: &mut Config, valid_screens: &Vec<String>) -> Result<Chi
|
||||||
])
|
])
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(if config.verbose {
|
.stdout(if config.verbose {
|
||||||
Stdio::piped()
|
|
||||||
} else {
|
|
||||||
Stdio::inherit()
|
Stdio::inherit()
|
||||||
|
} else {
|
||||||
|
Stdio::piped()
|
||||||
})
|
})
|
||||||
.stderr(if config.verbose {
|
.stderr(if config.verbose {
|
||||||
Stdio::piped()
|
|
||||||
} else {
|
|
||||||
Stdio::inherit()
|
Stdio::inherit()
|
||||||
|
} else {
|
||||||
|
Stdio::piped()
|
||||||
})
|
})
|
||||||
.spawn()?;
|
.spawn()?;
|
||||||
|
|
||||||
|
@ -164,8 +167,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
} else if arg == "-o" || arg == "--output" {
|
} else if arg == "-o" || arg == "--output" {
|
||||||
i += 1;
|
i += 1;
|
||||||
config.output = args[i].clone();
|
config.output = args[i].clone();
|
||||||
} else if arg == "-v" || arg == "--verbose" {
|
} else if arg == "--verbose" {
|
||||||
config.verbose = true;
|
config.verbose = true;
|
||||||
|
} else if arg == "-v" || arg == "--version" {
|
||||||
|
println!("v{}", VERSION);
|
||||||
|
std::process::exit(0);
|
||||||
} else if arg == "-h" || arg == "--help" {
|
} else if arg == "-h" || arg == "--help" {
|
||||||
help();
|
help();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue