Skip to main content

node_gui/
main.rs

1//! Desktop GUI for the `WoW Lab` distributed simulation node.
2
3// Keep the generated spec `inventory` registrations from being stripped.
4#[used]
5static FORCE_LINK: fn() -> usize = wowlab_engine_content::force_link_generated_specs;
6
7mod app;
8mod charts;
9mod cli;
10mod tray;
11mod ui;
12mod update;
13
14#[expect(
15    trivial_numeric_casts,
16    missing_debug_implementations,
17    unreachable_pub,
18    unused_qualifications,
19    clippy::clone_on_ref_ptr,
20    clippy::semicolon_outside_block,
21    reason = "Slint-generated Rust contains redundant ABI casts and private generated types"
22)]
23mod slint_generated {
24    slint::include_modules!();
25}
26
27use std::process::ExitCode;
28
29use clap::Parser;
30use cli::{Cli, Command};
31use mimalloc::MiMalloc;
32use slint_generated::{AppWindow, LogEntry};
33
34#[global_allocator]
35static GLOBAL: MiMalloc = MiMalloc;
36
37const VERSION: &str = env!("CARGO_PKG_VERSION");
38
39fn main() -> ExitCode {
40    let cli = Cli::parse();
41
42    match cli.command {
43        Some(Command::Update { check }) => match update::run_command(check) {
44            Ok(update::CommandSuccess::Available(version)) => {
45                println!("New version available: {version}");
46                println!("Run `node-gui update` to install");
47
48                ExitCode::SUCCESS
49            }
50            Ok(update::CommandSuccess::Current) => {
51                println!("Already on latest version");
52
53                ExitCode::SUCCESS
54            }
55            Ok(update::CommandSuccess::Installed) => ExitCode::SUCCESS,
56            Err(error) => {
57                eprintln!("{error}");
58
59                ExitCode::FAILURE
60            }
61        },
62        Some(Command::Run) | None => match ui::run(cli.no_update) {
63            Ok(()) => ExitCode::SUCCESS,
64            Err(error) => {
65                eprintln!("{error}");
66
67                ExitCode::FAILURE
68            }
69        },
70    }
71}