diff --git a/Cargo.lock b/Cargo.lock index 9b51d41..929c2d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1258,6 +1258,7 @@ dependencies = [ "atty", "bindgen", "c_fixed_string", + "cfg-if 1.0.0", "chrono", "cmake", "dateparser", diff --git a/Cargo.toml b/Cargo.toml index 90f2071..c291216 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ edition = "2018" [dependencies] atty = "0.2" c_fixed_string = { version = "0.2", optional = true } +cfg-if = "1" chrono = "0.4" dateparser = "0.1.6" derive_more = "0.99" diff --git a/src/main.rs b/src/main.rs index bc9a482..a3895d8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,6 @@ #[macro_use] +extern crate cfg_if; +#[macro_use] extern crate lazy_static; #[cfg(all(feature = "link-cplusplus", target_env = "gnu"))] extern crate link_cplusplus; diff --git a/src/opts.rs b/src/opts.rs index a58f1a5..d102166 100644 --- a/src/opts.rs +++ b/src/opts.rs @@ -568,7 +568,17 @@ pub fn parse_cmd() -> Option { } impl Default for CommandOpts { - fn default() -> Self { - Self::new(Command::None) + cfg_if! { + if #[cfg(test)] { + fn default() -> Self { + let mut re = Self::new(Command::None); + re.verbose = true; + re + } + } else { + fn default() -> Self { + Self::new(Command::None) + } + } } }