From 93346a3c00d96390eae2d708cce7e5adb648ca6f Mon Sep 17 00:00:00 2001 From: Trevor McMaster Date: Thu, 8 Sep 2022 09:51:31 -0600 Subject: [PATCH] Fixed an issue with out directories and stats file params - new versions of Clap panic with invalid utf8 passed to value_of_os() - https://github.com/clap-rs/clap/issues/3344 --- src/bin/pewpew.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bin/pewpew.rs b/src/bin/pewpew.rs index 9a97a9cc..3494d291 100644 --- a/src/bin/pewpew.rs +++ b/src/bin/pewpew.rs @@ -1,6 +1,6 @@ -use std::{convert::TryInto, fs::create_dir_all, io, path::PathBuf, time::UNIX_EPOCH}; +use std::{convert::TryInto, ffi::OsStr, fs::create_dir_all, io, path::PathBuf, time::UNIX_EPOCH}; -use clap::{crate_version, Arg, Command}; +use clap::{builder::ValueParser, crate_version, Arg, Command}; use config::duration_from_string; use futures::channel::mpsc as futures_channel; use log::{debug, info}; @@ -51,6 +51,7 @@ fn main() { .long("stats-file") .help("Specify the filename for the stats file") .value_name("STATS_FILE") + .value_parser(ValueParser::os_string()) ) .arg( Arg::new("start-at") @@ -72,6 +73,7 @@ fn main() { .number_of_values(1) .help("Directory to store results and logs") .value_name("DIRECTORY") + .value_parser(ValueParser::os_string()) ) .arg( Arg::new("stats-file-format") @@ -165,7 +167,7 @@ fn main() { .value_of("CONFIG") .expect("should have CONFIG param") .into(); - let results_dir = matches.value_of_os("results-directory").map(|d| { + let results_dir = matches.value_of_os("results-directory").map(|d: &OsStr| { create_dir_all(d).unwrap(); PathBuf::from(d) });