From e791d66ea64fa7a947c3b5d12f087d80d114d221 Mon Sep 17 00:00:00 2001 From: Yoshihito Date: Sat, 6 Jul 2019 13:03:06 +0900 Subject: [PATCH] Fix global `-p` option to work. (#17) --- src/config.rs | 1 + src/main.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index 3871c27..8ef2402 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3,6 +3,7 @@ use std::env; static OFFSET_KEY: &'static str = "UT_OFFSET"; static PRECISION_KEY: &'static str = "UT_PRECISION"; +#[derive(Debug)] pub struct Config { offset: Option, precision: Option, diff --git a/src/main.rs b/src/main.rs index 0f34cc0..bc9766e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -71,9 +71,13 @@ fn config() -> Config { fn run() -> Result<(), UtError> { let app = app(); let config = config(); - let precision = PrecisionArgv::default().parse_argv(config.precision().unwrap_or("second"))?; - let main_matches = app.get_matches(); + let precision = PrecisionArgv::default().parse_argv( + main_matches + .value_of("PRECISION") + .or(config.precision()) + .unwrap_or("second"), + )?; if main_matches.is_present("UTC") { let provider: UtcProvider = UtcProvider::from_timezone(Utc);