Skip to content

Commit

Permalink
💾 🧩 🎇 Feat, Refactor, Style: Optimized application.rs mainly
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed May 8, 2024
1 parent 0c3caf0 commit a9de442
Show file tree
Hide file tree
Showing 21 changed files with 760 additions and 645 deletions.
5 changes: 4 additions & 1 deletion KitX_Installer_Egui/rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
max_width = 200
max_width = 200
imports_granularity = "One"
imports_layout = "HorizontalVertical"
reorder_imports = true
7 changes: 7 additions & 0 deletions KitX_Installer_Egui/src/macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[macro_export]
macro_rules! report_error {
($content:expr) => {
println!($content);
eprintln!($content);
};
}
23 changes: 11 additions & 12 deletions KitX_Installer_Egui/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release

mod app_info;
mod data;
mod platforms;
mod utils;
mod views;

extern crate msgbox;

use {
crate::{
app_info::{AppInfo, RunMode},
utils::arguments_processor,
views::{application, font_helper},
views::{application, font_helper, native_helper},
},
arguments::Arguments,
platforms::windows::win_uninstaller,
std::env,
};

mod app_info;
mod data;
mod macros;
mod platforms;
mod utils;
mod views;

// Entry point of this program.
fn main() {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
Expand All @@ -30,8 +31,7 @@ fn main() {

// If failed to process arguments, exit.
if app_info.is_none() {
println!("Failed to process arguments.");
eprintln!("Failed to process arguments.");
report_error!("Failed to process command line arguments.");
return;
}

Expand All @@ -41,8 +41,7 @@ fn main() {
match &app_info.run_mode.as_ref().unwrap() {
RunMode::Gui => {
if run_gui(app_info).is_err() {
println!("Failed to run GUI.");
eprintln!("Failed to run GUI.");
report_error!("Failed to launch GUI.");
}
}
RunMode::Cli => {
Expand All @@ -63,7 +62,7 @@ fn run_gui(app_info: AppInfo) -> Result<(), eframe::Error> {
println!("Version: v{}", app_info.version);
println!();

let options = application::build_native_options(None);
let options = native_helper::build_native_options(None);

let result = eframe::run_native(
"KitX Installer",
Expand Down
1 change: 0 additions & 1 deletion KitX_Installer_Egui/src/platforms/windows/reg_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#[cfg(windows)]
use winreg::enums::*;

#[cfg(windows)]
use winreg::RegKey;

Expand Down
2 changes: 1 addition & 1 deletion KitX_Installer_Egui/src/platforms/windows/win_installer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use {
use {
super::reg_helper::delete_program_registry,
crate::{
data::{data_fetcher, download_config::DownloadConfig, install_config::InstallConfig},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use {
use {
super::reg_helper::{self, delete_program_registry},
std::{
fs,
Expand Down
2 changes: 1 addition & 1 deletion KitX_Installer_Egui/src/utils/arguments_processor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use {
use {
crate::{
app_info::{AppInfo, RunMode},
data::debug_config::DebugConfig,
Expand Down
Loading

0 comments on commit a9de442

Please sign in to comment.