mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-11-21 20:36:01 +03:00
feat: improved app args parsing
This commit is contained in:
parent
f86c86e1fd
commit
919de100c1
1 changed files with 19 additions and 15 deletions
34
src/main.rs
34
src/main.rs
|
@ -135,22 +135,24 @@ fn main() -> anyhow::Result<()> {
|
|||
let mut no_verbose_tracing = false;
|
||||
|
||||
let args = std::env::args().collect::<Vec<_>>();
|
||||
let mut gtk_args = Vec::new();
|
||||
|
||||
// Parse arguments
|
||||
for i in 0..args.len() {
|
||||
if args[i] == "--debug" {
|
||||
force_debug = true;
|
||||
} else if args[i] == "--run-game" {
|
||||
run_game = true;
|
||||
} else if args[i] == "--just-run-game" {
|
||||
just_run_game = true;
|
||||
} else if args[i] == "--no-verbose-tracing" {
|
||||
no_verbose_tracing = true;
|
||||
} else if args[i] == "--session" {
|
||||
// Switch active session prior running the app
|
||||
if let Some(session) = args.get(i + 1) {
|
||||
Sessions::set_current(session.to_owned())?;
|
||||
}
|
||||
match args[i].as_str() {
|
||||
"--debug" => force_debug = true,
|
||||
"--run-game" => run_game = true,
|
||||
"--just-run-game" => just_run_game = true,
|
||||
"--no-verbose-tracing" => no_verbose_tracing = true,
|
||||
|
||||
"--session" => {
|
||||
// Switch active session prior running the app
|
||||
if let Some(session) = args.get(i + 1) {
|
||||
Sessions::set_current(session.to_owned())?;
|
||||
}
|
||||
},
|
||||
|
||||
arg => gtk_args.push(arg.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,7 +212,8 @@ fn main() -> anyhow::Result<()> {
|
|||
// Run FirstRun window if .first-run file persist
|
||||
if FIRST_RUN_FILE.exists() {
|
||||
// Create the app
|
||||
let app = RelmApp::new(APP_ID);
|
||||
let app = RelmApp::new(APP_ID)
|
||||
.with_args(gtk_args);
|
||||
|
||||
// Set global css
|
||||
app.set_global_css(&GLOBAL_CSS);
|
||||
|
@ -243,7 +246,8 @@ fn main() -> anyhow::Result<()> {
|
|||
}
|
||||
|
||||
// Create the app
|
||||
let app = RelmApp::new(APP_ID);
|
||||
let app = RelmApp::new(APP_ID)
|
||||
.with_args(gtk_args);
|
||||
|
||||
// Set global css
|
||||
app.set_global_css(&GLOBAL_CSS);
|
||||
|
|
Loading…
Reference in a new issue