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 mut no_verbose_tracing = false;
|
||||||
|
|
||||||
let args = std::env::args().collect::<Vec<_>>();
|
let args = std::env::args().collect::<Vec<_>>();
|
||||||
|
let mut gtk_args = Vec::new();
|
||||||
|
|
||||||
// Parse arguments
|
// Parse arguments
|
||||||
for i in 0..args.len() {
|
for i in 0..args.len() {
|
||||||
if args[i] == "--debug" {
|
match args[i].as_str() {
|
||||||
force_debug = true;
|
"--debug" => force_debug = true,
|
||||||
} else if args[i] == "--run-game" {
|
"--run-game" => run_game = true,
|
||||||
run_game = true;
|
"--just-run-game" => just_run_game = true,
|
||||||
} else if args[i] == "--just-run-game" {
|
"--no-verbose-tracing" => no_verbose_tracing = true,
|
||||||
just_run_game = true;
|
|
||||||
} else if args[i] == "--no-verbose-tracing" {
|
"--session" => {
|
||||||
no_verbose_tracing = true;
|
// Switch active session prior running the app
|
||||||
} else if args[i] == "--session" {
|
if let Some(session) = args.get(i + 1) {
|
||||||
// Switch active session prior running the app
|
Sessions::set_current(session.to_owned())?;
|
||||||
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
|
// Run FirstRun window if .first-run file persist
|
||||||
if FIRST_RUN_FILE.exists() {
|
if FIRST_RUN_FILE.exists() {
|
||||||
// Create the app
|
// Create the app
|
||||||
let app = RelmApp::new(APP_ID);
|
let app = RelmApp::new(APP_ID)
|
||||||
|
.with_args(gtk_args);
|
||||||
|
|
||||||
// Set global css
|
// Set global css
|
||||||
app.set_global_css(&GLOBAL_CSS);
|
app.set_global_css(&GLOBAL_CSS);
|
||||||
|
@ -243,7 +246,8 @@ fn main() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the app
|
// Create the app
|
||||||
let app = RelmApp::new(APP_ID);
|
let app = RelmApp::new(APP_ID)
|
||||||
|
.with_args(gtk_args);
|
||||||
|
|
||||||
// Set global css
|
// Set global css
|
||||||
app.set_global_css(&GLOBAL_CSS);
|
app.set_global_css(&GLOBAL_CSS);
|
||||||
|
|
Loading…
Reference in a new issue