mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Parse settings from the command line (#1578)
Allow specifying any setting as --setting=value Sections other than main: --section.setting=value Previous positional arguments are still supported Update user manual with quick usage and examples
This commit is contained in:
parent
9af9fe78ee
commit
172e25fef0
5 changed files with 597 additions and 495 deletions
|
|
@ -79,7 +79,7 @@ namespace MinecraftClient
|
|||
//Process ini configuration file
|
||||
if (args.Length >= 1 && System.IO.File.Exists(args[0]) && System.IO.Path.GetExtension(args[0]).ToLower() == ".ini")
|
||||
{
|
||||
Settings.LoadSettings(args[0]);
|
||||
Settings.LoadFile(args[0]);
|
||||
|
||||
//remove ini configuration file from arguments array
|
||||
List<string> args_tmp = args.ToList<string>();
|
||||
|
|
@ -88,7 +88,7 @@ namespace MinecraftClient
|
|||
}
|
||||
else if (System.IO.File.Exists("MinecraftClient.ini"))
|
||||
{
|
||||
Settings.LoadSettings("MinecraftClient.ini");
|
||||
Settings.LoadFile("MinecraftClient.ini");
|
||||
}
|
||||
else Settings.WriteDefaultSettings("MinecraftClient.ini");
|
||||
|
||||
|
|
@ -98,20 +98,26 @@ namespace MinecraftClient
|
|||
//Other command-line arguments
|
||||
if (args.Length >= 1)
|
||||
{
|
||||
Settings.Login = args[0];
|
||||
if (args.Length >= 2)
|
||||
if (args.Contains("--help"))
|
||||
{
|
||||
Settings.Password = args[1];
|
||||
if (args.Length >= 3)
|
||||
{
|
||||
Settings.SetServerIP(args[2]);
|
||||
Console.WriteLine("Command-Line Help:");
|
||||
Console.WriteLine("MinecraftClient.exe <username> <password> <server>");
|
||||
Console.WriteLine("MinecraftClient.exe <username> <password> <server> \"/mycommand\"");
|
||||
Console.WriteLine("MinecraftClient.exe --setting=value [--other settings]");
|
||||
Console.WriteLine("MinecraftClient.exe --section.setting=value [--other settings]");
|
||||
Console.WriteLine("MinecraftClient.exe <settings-file.ini> [--other settings]");
|
||||
return;
|
||||
}
|
||||
|
||||
//Single command?
|
||||
if (args.Length >= 4)
|
||||
{
|
||||
Settings.SingleCommand = args[3];
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
Settings.LoadArguments(args);
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
Settings.interactiveMode = false;
|
||||
HandleFailure(e.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue