diff --git a/src/engine/params.rs b/src/engine/params.rs index 8eef148..62a8622 100644 --- a/src/engine/params.rs +++ b/src/engine/params.rs @@ -22,7 +22,11 @@ impl Params { Err(_) => { return Err(format!( "Could not load .env file {:?}", - base_dir.config_dir().join("deepl/.env").as_path() + base_dir + .config_dir() + .join("deepl/.env") + .as_path() + .as_os_str() )); } }; @@ -32,7 +36,7 @@ impl Params { Ok(Self { source_lang: matches.value_of("source").unwrap_or("0").to_string(), - target_lang: matches.value_of("target").unwrap_or("EN-US").to_string(), + target_lang: matches.value_of("target").unwrap_or("DE").to_string(), key: env::var("KEY").unwrap(), uri: env::var("URI").unwrap(), text: matches.value_of("INPUT").unwrap().to_string(), diff --git a/src/main.rs b/src/main.rs index 7dea481..75774e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,17 +1,23 @@ mod engine; -use hyper::{Body, Client, Method, Request, body}; -use hyper_tls::HttpsConnector; use crate::engine::params::Params; use crate::engine::response::DeeplResponse; +use hyper::{body, Body, Client, Method, Request}; +use hyper_tls::HttpsConnector; - -#[tokio::main(flavor = "current_thread")] +#[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), Box> { let https = HttpsConnector::new(); let client = Client::builder().build::<_, hyper::Body>(https); - let params = Params::new()?; + // let params: Params = Params::new()?; + let params: Params = match Params::new() { + Ok(result) => result, + Err(e) => { + eprintln!("{}", e); + return Ok(()); + }, + }; let request = Request::builder() .method(Method::POST)