mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-03 16:25:35 +00:00
replaced const with cli argument
This commit is contained in:
parent
191264e732
commit
ad49713e13
32
Cargo.lock
generated
32
Cargo.lock
generated
@ -74,6 +74,37 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "argh"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7af5ba06967ff7214ce4c7419c7d185be7ecd6cc4965a8f6e1d8ce0398aad219"
|
||||
dependencies = [
|
||||
"argh_derive",
|
||||
"argh_shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "argh_derive"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56df0aeedf6b7a2fc67d06db35b09684c3e8da0c95f8f27685cb17e08413d87a"
|
||||
dependencies = [
|
||||
"argh_shared",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "argh_shared"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5693f39141bda5760ecc4111ab08da40565d1771038c4a0250f03457ec707531"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.74"
|
||||
@ -128,6 +159,7 @@ name = "beammp_rust_server"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"argh",
|
||||
"async-trait",
|
||||
"crossterm",
|
||||
"flate2",
|
||||
|
@ -9,6 +9,8 @@ edition = "2021"
|
||||
log = "0.4"
|
||||
pretty_env_logger = "0.4.0"
|
||||
|
||||
argh = "0.1.12"
|
||||
|
||||
lazy_static = "1"
|
||||
|
||||
anyhow = "1.0.66"
|
||||
|
16
src/main.rs
16
src/main.rs
@ -2,6 +2,8 @@
|
||||
#[macro_use] extern crate async_trait;
|
||||
#[macro_use] extern crate lazy_static;
|
||||
|
||||
use argh::FromArgs;
|
||||
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
@ -11,11 +13,19 @@ mod server;
|
||||
mod config;
|
||||
mod heartbeat;
|
||||
|
||||
const USE_TUI_CONSOLE_UI: bool = true; // true = uses tui.rs. false = uses pretty_env_logger (useful when developing)
|
||||
#[derive(FromArgs)]
|
||||
/// BeamMP Server v3.3.0
|
||||
struct Args {
|
||||
/// disables the TUI and shows a simple console log instead
|
||||
#[argh(switch)]
|
||||
disable_tui: bool,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
if USE_TUI_CONSOLE_UI {
|
||||
let args: Args = argh::from_env();
|
||||
|
||||
if !args.disable_tui {
|
||||
logger::init(log::LevelFilter::max()).expect("Failed to enable logger!");
|
||||
} else {
|
||||
// pretty_env_logger::formatted_timed_builder().filter_level(log::LevelFilter::max()).init();
|
||||
@ -53,7 +63,7 @@ async fn main() {
|
||||
|
||||
let (cmd_tx, cmd_rx) = mpsc::channel(100);
|
||||
|
||||
if USE_TUI_CONSOLE_UI {
|
||||
if !args.disable_tui {
|
||||
tokio::spawn(tui::tui_main(user_config.clone(), cmd_tx));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user