added verboses output
parent
6907656cf2
commit
5151932cda
|
|
@ -152,7 +152,7 @@ checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b"
|
|||
|
||||
[[package]]
|
||||
name = "deepl"
|
||||
version = "1.0.4"
|
||||
version = "1.0.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "deepl"
|
||||
version = "1.0.4"
|
||||
version = "1.0.5"
|
||||
edition = "2024"
|
||||
license = "MIT OR Apache-2.0"
|
||||
authors = ["Mathias Rothenhäusler <safemind@posteo.net"]
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ Required keys URI (eg. https://api-free.deepl.com/v2/translate) and KEY (eg. XY
|
|||
### OPTIONS:
|
||||
-s, --source <source_lang> The language you want to translate. Default is autodectect.
|
||||
-t, --target <target_lang> The language your text should be tranlated to. Default is DE.
|
||||
-v, --verbos <verbose> Verbose output
|
||||
|
||||
### ARGS:
|
||||
<INPUT> Text to translate
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ pub struct Cli {
|
|||
#[arg(short, long, default_value = "DE")]
|
||||
pub target: String,
|
||||
|
||||
/// verbose output
|
||||
#[arg(short, long)]
|
||||
pub verbose: bool,
|
||||
|
||||
/// Text to translate
|
||||
pub input: String,
|
||||
}
|
||||
|
|
@ -30,6 +34,7 @@ pub struct Params {
|
|||
pub key: String,
|
||||
pub uri: String,
|
||||
pub input: String,
|
||||
pub verbose: bool,
|
||||
}
|
||||
|
||||
impl Params {
|
||||
|
|
@ -50,6 +55,7 @@ impl Params {
|
|||
input: cli.input,
|
||||
key: env::var("KEY").context("KEY env var missing")?,
|
||||
uri: env::var("URI").context("URI env var missing")?,
|
||||
verbose: cli.verbose
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ async fn main() -> Result<()> {
|
|||
let res = client.request(request).await?;
|
||||
let body_bytes = body::to_bytes(res.into_body()).await?;
|
||||
let body = String::from_utf8(body_bytes.to_vec())?;
|
||||
|
||||
if params.verbose {
|
||||
println!("{}", &body);
|
||||
}
|
||||
|
||||
let v: DeeplResponse =
|
||||
serde_json::from_str(&body).context(format!("Could not parse body: {}", body))?;
|
||||
println!("{}", v.get_text(¶ms)?);
|
||||
|
|
|
|||
Loading…
Reference in New Issue