A few updates:
The CommandContext
The special DebugConsole parameter has been replaced with CommandContext. This new argument wraps the Print and Clear calls even in a headless context. For example:
[Command("test", isCheat, "this is a command")]
private static void TestCommand(CommandContext context, int foo, float bar, string baz)
{
context.Print($"Foo is {foo}, bar is {bar} and the baz message is {baz}");
}
Please note that in non-headless contexts this only prints to the invoker Debug Console. Use GD.Print to print to the global logs.
Optional Command Parameters
Optional parameters are now supported in the command signature. This is an example from a command implemented in the game:
private static void CommandManageHistory(CommandContext context, HistoryCommandMode mode = HistoryCommandMode.Show,
string attribute = "")
{
// Some logic
}
You can invoke this command from the console with or without the optional arguments, with the interpreter automatically filling in the default values. Please note that it’s not (yet) possible to declare specific optional parameters, and the order must be respected. For example, you can’t specify the attribute parameter in the command without first specifying mode first.