pay-respects/src/main.rs

75 lines
1.8 KiB
Rust
Raw Normal View History

// pay-respects: Press F to correct your command
2023-08-09 00:14:54 +02:00
// Copyright (C) 2023 iff
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
2024-11-13 16:31:31 +01:00
use sys_locale::get_locale;
2023-07-31 14:27:44 +02:00
mod args;
2023-08-03 21:26:41 +02:00
mod files;
mod rules;
2023-07-30 18:40:18 +02:00
mod shell;
mod style;
2023-08-01 20:29:02 +02:00
mod suggestions;
2024-11-23 22:18:33 +01:00
mod modes;
2023-07-30 18:40:18 +02:00
2024-11-15 15:43:04 +01:00
#[cfg(feature = "runtime-rules")]
mod replaces;
#[cfg(feature = "runtime-rules")]
mod runtime_rules;
2024-11-19 14:59:15 +01:00
#[cfg(feature = "request-ai")]
mod requests;
2024-09-25 17:55:55 +02:00
#[macro_use]
extern crate rust_i18n;
i18n!("i18n", fallback = "en", minify_key = true);
2023-07-30 18:40:18 +02:00
fn main() {
2023-08-12 22:39:00 +02:00
colored::control::set_override(true);
2024-11-13 16:31:31 +01:00
// let locale = std::env::var("LANG").unwrap_or("en_US".to_string());
2024-11-23 00:02:34 +01:00
let locale = {
let sys_locale = get_locale().unwrap_or("en-US".to_string());
if sys_locale.len() < 2 {
"en_US".to_string()
} else {
sys_locale
}
};
2024-09-26 03:02:00 +02:00
rust_i18n::set_locale(&locale[0..2]);
2023-08-12 22:39:00 +02:00
2024-11-19 14:59:15 +01:00
#[cfg(feature = "request-ai")]
{
2024-11-20 21:16:14 +01:00
if std::env::var("_PR_AI_LOCALE").is_err() {
std::env::set_var("_PR_AI_LOCALE", &locale);
}
2024-11-19 14:59:15 +01:00
}
args::handle_args();
2023-07-30 18:40:18 +02:00
2024-11-23 22:18:33 +01:00
let mode = match std::env::var("_PR_MODE") {
Ok(mode) => mode,
Err(_) => {
2024-11-23 22:18:33 +01:00
"suggestion".to_string()
}
};
2024-11-23 22:18:33 +01:00
match mode.as_str() {
"suggestion" => modes::suggestion(),
"cnf" => modes::cnf(),
_ => {
2023-07-31 23:42:19 +02:00
}
2023-07-30 18:40:18 +02:00
}
}