Skip to content

Commit

Permalink
Always add "tray" and "open" to the root command + description
Browse files Browse the repository at this point in the history
  • Loading branch information
gablm committed Jan 11, 2024
1 parent 87ef616 commit cb07a48
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions CollapseLauncher/Classes/Properties/ArgumentParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ public static void ParseArguments(params string[] args)
break;
case "tray":
m_appMode = AppMode.StartOnTray;
ParseStartOnTrayArguments(args);
break;
case "open":
m_appMode = AppMode.Launcher;
ParseStartGameArguments(args);
break;
}

AddPublicCommands();
rootCommand.Description = "Collapse Launcher is a game client for all currently released miHoYo/Hoyoverse games.\n" +
"It supports installing games, repairing game files and much more!";

if (rootCommand.Invoke(args) > 0)
{
new ArgumentException($"Argument to run this command is invalid! See the information above for more detail.");
Expand Down Expand Up @@ -139,11 +141,6 @@ public static void ParseOOBEArguments(params string[] args)
rootCommand.AddArgument(new Argument<string>("oobesetup", "Starts Collapse in OOBE mode, to simulate first-time setup") { HelpName = null });
}

public static void ParseStartOnTrayArguments(params string[] args)
{
rootCommand.AddArgument(new Argument<string>("tray", "Start Collapse in system tray") { HelpName = null });
}

private static void AddMigrateOptions(bool isBHI3L)
{
var inputOption = new Option<string>(new string[] { "--input", "-i" }, description: "Installation Source") { IsRequired = true };
Expand Down Expand Up @@ -212,16 +209,20 @@ public static void ParseMoveSteamArguments(params string[] args)
rootCommand.AddCommand(command);
}

private static void ParseStartGameArguments(params string[] args)
private static void AddPublicCommands()
{
rootCommand.AddCommand(new Command("tray", "Start Collapse in system tray"));
AddOpenCommand();
}

private static void AddOpenCommand()
{
var gameOption = new Option<string>(new string[] { "--game", "-g" },
description: "Game number/name\n" +
"e.g. 0 or \"Honkai Impact 3rd\""
) { IsRequired = true, AllowMultipleArgumentsPerToken = true };
var gameOption = new Option<string>(new string[] { "--game", "-g" },
description: "Game number/name\n" +
"e.g. 0 or \"Honkai Impact 3rd\""){ IsRequired = true };
var regionOption = new Option<string>(new string[] { "--region", "-r" },
description: "Region number/name\n" +
"e.g. For Genshin Impact, 0 or \"Global\" would load the Global region for the game"
) { IsRequired = false, AllowMultipleArgumentsPerToken = true };
description: "Region number/name\n" +
"e.g. For Genshin Impact, 0 or \"Global\" would load the Global region for the game") { IsRequired = false };
var startGameOption = new Option<bool>(new string[] { "--play", "-p" }, description: "Start Game after loading the Game/Region") { IsRequired = false };
var command = new Command("open", "Open the Launcher in a specific Game and Region (if specified).\n" +
"Note that game/regions provided will be ignored if invalid.\n" +
Expand Down

0 comments on commit cb07a48

Please sign in to comment.