mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-13 06:50:09 +01:00
chore: rearrange directories
This commit is contained in:
parent
d5fb7462e0
commit
4c9aac45a8
46 changed files with 11 additions and 18 deletions
86
core/src/main.rs
Normal file
86
core/src/main.rs
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
// pay-respects: Press F to correct your command
|
||||
// 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/>.
|
||||
|
||||
use sys_locale::get_locale;
|
||||
|
||||
mod args;
|
||||
mod modes;
|
||||
mod rules;
|
||||
mod shell;
|
||||
mod style;
|
||||
mod suggestions;
|
||||
mod system;
|
||||
|
||||
#[macro_use]
|
||||
extern crate rust_i18n;
|
||||
i18n!("i18n", fallback = "en", minify_key = true);
|
||||
|
||||
fn main() -> Result<(), std::io::Error> {
|
||||
colored::control::set_override(true);
|
||||
let init = init();
|
||||
let mut data = if let Err(status) = init {
|
||||
match status {
|
||||
args::Status::Exit => {
|
||||
return Ok(());
|
||||
}
|
||||
args::Status::Error => {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::InvalidInput,
|
||||
"Invalid input",
|
||||
));
|
||||
}
|
||||
_ => {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
init.ok().unwrap()
|
||||
};
|
||||
|
||||
data.expand_command();
|
||||
use shell::Mode::*;
|
||||
match data.mode {
|
||||
Suggestion => modes::suggestion(&mut data),
|
||||
Cnf => modes::cnf(&mut data),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn init() -> Result<shell::Data, args::Status> {
|
||||
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
|
||||
}
|
||||
};
|
||||
rust_i18n::set_locale(&locale[0..2]);
|
||||
|
||||
let status = args::handle_args();
|
||||
match status {
|
||||
args::Status::Exit => {
|
||||
return Err(status);
|
||||
}
|
||||
args::Status::Error => {
|
||||
return Err(status);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Ok(shell::Data::init())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue