added some params

This commit is contained in:
2021-09-17 16:22:50 +02:00
parent 0125dfe26c
commit 10079766f3
4 changed files with 135 additions and 1 deletions
+27
View File
@@ -0,0 +1,27 @@
name: deepl
version: "1.0"
author: Mathias Rothenhaeusler <safemind@posteo.net>
about: Cli API for deepl translations.
args:
- source:
short: s
long: source
value_name: source_lang
help: The language you want to translate.
takes_value: true
required: false
- target:
short: t
long: target
value_name: target_lang
help: The language your text should be tranlated to.
takes_value: true
required: false
- file:
short: f
long: file
desc: File you want to translate.
help: Csv delimiter character
required: false
takes_value: true
+34
View File
@@ -0,0 +1,34 @@
pub mod deepl_helper {
use clap::ArgMatches;
pub struct Params {
source_lang: String,
destination_lang: String,
file: String,
}
impl Params {
pub fn new_from_matches(matches: ArgMatches) -> Self {
Self {
source_lang: matches.value_of("source_lang").unwrap_or("EN").to_string(),
destination_lang: matches
.value_of("destination_lang")
.unwrap_or("DE")
.to_string(),
file: matches.value_of("file").unwrap_or_default().to_string(),
}
}
pub fn source(&self) -> &String {
&self.source_lang
}
pub fn dest(&self) -> &String {
&self.destination_lang
}
pub fn file(&self) -> &String {
&self.file
}
}
}