From 8bf57f64b930b65367a5ddb072a13b1e9354c8f0 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Wed, 8 Aug 2018 14:41:59 +0800 Subject: Check LANG before default to en --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 90eed78..25e6e32 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,7 +72,10 @@ fn parse_arguments() -> Configuration { std::process::exit(0); } - let lang = matches.value_of("lang").unwrap_or("en").to_string(); + let lang = matches + .value_of("lang") + .or(option_env!("LANG").map(|s| s.split_at(2).0)) + .unwrap_or("en"); let wiki_url = matches .value_of("URL") .unwrap_or(&format!("https://{}.wikipedia.org", lang)) -- cgit v1.2.3