From e35b8520b4837db0c5f7f20ff6577b990b7a02cc Mon Sep 17 00:00:00 2001 From: Slavasil Date: Sun, 23 Mar 2025 22:01:59 +0300 Subject: [PATCH] add command-line options support new command-line option "--bank " can be specified to be used instead of the game config option --- App/CommandLineOptions.cs | 17 ++++++++++++++++- App/Program.cs | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/App/CommandLineOptions.cs b/App/CommandLineOptions.cs index 0659208..0fe462f 100644 --- a/App/CommandLineOptions.cs +++ b/App/CommandLineOptions.cs @@ -1,7 +1,22 @@ namespace Game { public struct CommandLineOptions { + public string? databaseFilename = null; + public CommandLineOptions() { + + } public static CommandLineOptions Parse(string[] args) { - return new CommandLineOptions(); + string? databaseFilename = null; + for (int i = 0; i < args.Length; ++i) { + string arg = args[i]; + if (arg.StartsWith("--bank")) { + if (arg.Length > 6 && arg[6] == '=') { + databaseFilename = arg.Substring(7); + } else if (args.Length > i + 1) { + databaseFilename = args[i + 1]; + } + } + } + return new CommandLineOptions() { databaseFilename = databaseFilename }; } } } \ No newline at end of file diff --git a/App/Program.cs b/App/Program.cs index 5e41ec9..4dd9c2e 100644 --- a/App/Program.cs +++ b/App/Program.cs @@ -29,7 +29,7 @@ namespace Game { return 2; } - string databaseFileName = gameConfig.databasePath; + string databaseFileName = opts.databaseFilename ?? gameConfig.databasePath; display.ResetWindow();