change default language

master
Mathias Rothenhaeusler 2021-09-18 10:59:51 +02:00
parent 087c1dc117
commit 00e2913b7a
3 changed files with 20 additions and 6 deletions

16
.gitignore vendored
View File

@ -1 +1,15 @@
/target .vscode/
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

View File

@ -7,14 +7,14 @@ args:
short: s short: s
long: source long: source
value_name: source_lang value_name: source_lang
help: The language you want to translate. Default is EN_US help: The language you want to translate. Default is DE
takes_value: true takes_value: true
required: false required: false
- target: - target:
short: t short: t
long: target long: target
value_name: target_lang value_name: target_lang
help: The language your text should be tranlated to. Default is DE help: The language your text should be tranlated to. Default is EN-US
takes_value: true takes_value: true
required: false required: false
- file: - file:

View File

@ -26,17 +26,17 @@ pub mod deepl_helper {
let my_path = base_dir.config_dir().join("deepl/.env"); let my_path = base_dir.config_dir().join("deepl/.env");
match dotenv::from_path(my_path.as_path()) { match dotenv::from_path(my_path.as_path()) {
Ok(env) => env, Ok(env) => env,
Err(_) => panic!("could not load .env file {:?}", my_path.as_path()), Err(_) => panic!("Could not load .env file {:?}", my_path.as_path()),
}; };
let yaml = load_yaml!("cli.yml"); let yaml = load_yaml!("cli.yml");
let matches = App::from_yaml(yaml).get_matches(); let matches = App::from_yaml(yaml).get_matches();
Self { Self {
source_lang: matches.value_of("source").unwrap_or("EN").to_string(), source_lang: matches.value_of("source").unwrap_or("DE").to_string(),
target_lang: matches target_lang: matches
.value_of("target") .value_of("target")
.unwrap_or("DE") .unwrap_or("EN-US")
.to_string(), .to_string(),
file: matches.value_of("file").unwrap_or_default().to_string(), file: matches.value_of("file").unwrap_or_default().to_string(),
key: env::var("key").unwrap(), key: env::var("key").unwrap(),