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
|
//Process ini configuration file
|
||||||
if (args.Length >= 1 && System.IO.File.Exists(args[0]) && System.IO.Path.GetExtension(args[0]).ToLower() == ".ini")
|
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
|
//remove ini configuration file from arguments array
|
||||||
List<string> args_tmp = args.ToList<string>();
|
List<string> args_tmp = args.ToList<string>();
|
||||||
|
|
@ -88,7 +88,7 @@ namespace MinecraftClient
|
||||||
}
|
}
|
||||||
else if (System.IO.File.Exists("MinecraftClient.ini"))
|
else if (System.IO.File.Exists("MinecraftClient.ini"))
|
||||||
{
|
{
|
||||||
Settings.LoadSettings("MinecraftClient.ini");
|
Settings.LoadFile("MinecraftClient.ini");
|
||||||
}
|
}
|
||||||
else Settings.WriteDefaultSettings("MinecraftClient.ini");
|
else Settings.WriteDefaultSettings("MinecraftClient.ini");
|
||||||
|
|
||||||
|
|
@ -98,20 +98,26 @@ namespace MinecraftClient
|
||||||
//Other command-line arguments
|
//Other command-line arguments
|
||||||
if (args.Length >= 1)
|
if (args.Length >= 1)
|
||||||
{
|
{
|
||||||
Settings.Login = args[0];
|
if (args.Contains("--help"))
|
||||||
if (args.Length >= 2)
|
|
||||||
{
|
{
|
||||||
Settings.Password = args[1];
|
Console.WriteLine("Command-Line Help:");
|
||||||
if (args.Length >= 3)
|
Console.WriteLine("MinecraftClient.exe <username> <password> <server>");
|
||||||
{
|
Console.WriteLine("MinecraftClient.exe <username> <password> <server> \"/mycommand\"");
|
||||||
Settings.SetServerIP(args[2]);
|
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?
|
try
|
||||||
if (args.Length >= 4)
|
{
|
||||||
{
|
Settings.LoadArguments(args);
|
||||||
Settings.SingleCommand = args[3];
|
}
|
||||||
}
|
catch (ArgumentException e)
|
||||||
}
|
{
|
||||||
|
Settings.interactiveMode = false;
|
||||||
|
HandleFailure(e.Message);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,9 @@ error.connection_timeout=§8Es gab einen Timeout während des Verbindungsaufbaus
|
||||||
error.forge=§8Forge Login Handshake konnte nicht erfolgreich abgeschlossen werden.
|
error.forge=§8Forge Login Handshake konnte nicht erfolgreich abgeschlossen werden.
|
||||||
error.forge_encrypt=§8Forge StartEncryption Handshake konnte nicht erfolgreich abgeschlossen werden.
|
error.forge_encrypt=§8Forge StartEncryption Handshake konnte nicht erfolgreich abgeschlossen werden.
|
||||||
error.setting.str2int=Konnte '{0}' nicht in einen Int umwandeln. Bitte überprüfe die Einstellungen.
|
error.setting.str2int=Konnte '{0}' nicht in einen Int umwandeln. Bitte überprüfe die Einstellungen.
|
||||||
|
error.setting.argument_syntax={0}: Invalid syntax, expecting --argname=value or --section.argname=value
|
||||||
|
error.setting.unknown_section={0}: Unknown setting section '{1}'
|
||||||
|
error.setting.unknown_or_invalid={0}: Unknown setting or invalid value
|
||||||
error.http_code=§8Es gab einen Fehlercode vom Server: {0}
|
error.http_code=§8Es gab einen Fehlercode vom Server: {0}
|
||||||
error.auth=§8Es gab einen Fehlercode vom Server, während die Authentication erneuert wurde: {0}
|
error.auth=§8Es gab einen Fehlercode vom Server, während die Authentication erneuert wurde: {0}
|
||||||
error.realms.ip_error=Konnte die Server-IP deiner Realms-Welt nicht abfragen
|
error.realms.ip_error=Konnte die Server-IP deiner Realms-Welt nicht abfragen
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,9 @@ error.connection_timeout=§8A timeout occured while attempting to connect to thi
|
||||||
error.forge=§8Forge Login Handshake did not complete successfully
|
error.forge=§8Forge Login Handshake did not complete successfully
|
||||||
error.forge_encrypt=§8Forge StartEncryption Handshake did not complete successfully
|
error.forge_encrypt=§8Forge StartEncryption Handshake did not complete successfully
|
||||||
error.setting.str2int=Failed to convert '{0}' into an int. Please check your settings.
|
error.setting.str2int=Failed to convert '{0}' into an int. Please check your settings.
|
||||||
|
error.setting.argument_syntax={0}: Invalid syntax, expecting --argname=value or --section.argname=value
|
||||||
|
error.setting.unknown_section={0}: Unknown setting section '{1}'
|
||||||
|
error.setting.unknown_or_invalid={0}: Unknown setting or invalid value
|
||||||
error.http_code=§8Got error code from server: {0}
|
error.http_code=§8Got error code from server: {0}
|
||||||
error.auth=§8Got error code from server while refreshing authentication: {0}
|
error.auth=§8Got error code from server while refreshing authentication: {0}
|
||||||
error.realms.ip_error=Cannot retrieve the server IP of your Realms world
|
error.realms.ip_error=Cannot retrieve the server IP of your Realms world
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -50,25 +50,59 @@ You can have several INI files and drag & drop one of them over MinecraftClient.
|
||||||
Command-line usage
|
Command-line usage
|
||||||
------
|
------
|
||||||
|
|
||||||
**MinecraftClient.exe username password server:**
|
Quick usage:
|
||||||
|
|
||||||
This will automatically connect you to the chosen server.
|
```
|
||||||
To specify a server and ask password interactively, use "" as password.
|
MinecraftClient.exe --help
|
||||||
To specify offline mode with no password, use "-" as password.
|
MinecraftClient.exe <username> <password> <server>
|
||||||
|
MinecraftClient.exe <username> <password> <server> "/mycommand"
|
||||||
|
MinecraftClient.exe --setting=value [--other settings]
|
||||||
|
MinecraftClient.exe --section.setting=value [--other settings]
|
||||||
|
MinecraftClient.exe <settings-file.ini> [--other settings]
|
||||||
|
```
|
||||||
|
You can mix and match arguments by following theses rules:
|
||||||
|
* First positional argument may be either the login or settings file
|
||||||
|
* Other positional arguments are read in order: login, password, server, command
|
||||||
|
* Arguments starting with `--` can be in any order and position
|
||||||
|
|
||||||
**MinecraftClient.exe username password server "/mycommand":**
|
Examples and further explanations:
|
||||||
|
|
||||||
This will automatically send "/mycommand" to the server and close.
|
```
|
||||||
To send several commands and maybe stay connected, use the Scripting bot instead.
|
MinecraftClient.exe <login> <password> <server>
|
||||||
|
```
|
||||||
|
|
||||||
**MinecraftClient.exe myconfig.ini:**
|
* This will automatically connect you to the chosen server.
|
||||||
|
* You may omit password and/or server to specify e.g. only the login
|
||||||
|
* To specify a server but ask password interactively, use `""` as password.
|
||||||
|
* To specify offline mode with no password, use `-` as password.
|
||||||
|
|
||||||
This will load the specified configuration file
|
```
|
||||||
If the file contains login / password / server ip, it will automatically connect.
|
MinecraftClient.exe <login> <password> <server> "/mycommand"
|
||||||
|
```
|
||||||
|
|
||||||
**MinecraftClient.exe myconfig.ini othername otherpassword otherIP:**
|
* This will automatically send `/mycommand` to the server and close.
|
||||||
|
* To send several commands and/or stay connected, use the ScriptScheduler bot instead.
|
||||||
|
|
||||||
Load the specified configuration file and override some settings from the file.
|
```
|
||||||
|
MinecraftClient.exe <myconfig.ini>
|
||||||
|
```
|
||||||
|
|
||||||
|
* This will load the specified configuration file
|
||||||
|
* If the file contains login / password / server ip, it will automatically connect.
|
||||||
|
|
||||||
|
```
|
||||||
|
MinecraftClient.exe --setting=value [--other settings]
|
||||||
|
```
|
||||||
|
|
||||||
|
* Specify settings on the command-line, see possible value in the configuration file
|
||||||
|
* Use `--section.setting=value` for settings outside the `[Main]` section
|
||||||
|
* Example: `--antiafk.enabled=true` for enabling the AntiAFK bot
|
||||||
|
|
||||||
|
```
|
||||||
|
MinecraftClient.exe <myconfig.ini> <login> <password> <server> [--other settings]
|
||||||
|
```
|
||||||
|
|
||||||
|
* Load the specified configuration file and override some settings from the file
|
||||||
|
|
||||||
Internal commands
|
Internal commands
|
||||||
------
|
------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue