mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* Console command completions v1.
I think it works™️
* Unify cvar commands
* Handle no-completions-at-all better.
* Don't crash if you tab complete while no completions available.
* Always show hints if available
* Properly null completion hint over the wire
* Unify help command, localize it.
* Clean up + localize cvar command.
* Remove debug logging
* List command unified & localized.
* Remove server completions debug logging
* Remote execute command.
Had to make everything async for this.
* Don't lower case enums or bools
Why
* GC commands converted and localized.
* Fix remote command completions.
Whoops
* Kick command completions
* lsasm unified & localized.
* Revert "Don't lower case enums or bools"
This reverts commit 2f825347c3.
* ToString gc_mode command enums instead of trying to fix Fluent.
Ah well.
* Unify szr_stats
* Unify log commands, completions
* Fix compile
* Improve completion with complex cases (quotes, escapes)
* Code cleanup, comments.
* Fix tab completion with empty arg ruining everything.
* Fix RegisteredCommand completions
* Add more complex completion options system.
* Refactor content directory entries into a proper resource manager API.
* Implement GetEntries for DirLoader
* Make type hint darker.
* Exec command autocomplete, pulled play global sound code out to engine.
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System.Linq;
|
|
using Robust.Shared.Localization;
|
|
|
|
namespace Robust.Shared.Console.Commands;
|
|
|
|
internal sealed class HelpCommand : IConsoleCommand
|
|
{
|
|
public string Command => "help";
|
|
public string Description => Loc.GetString("cmd-help-desc");
|
|
public string Help => Loc.GetString("cmd-help-help");
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
switch (args.Length)
|
|
{
|
|
case 0:
|
|
shell.WriteLine(Loc.GetString("cmd-help-no-args"));
|
|
break;
|
|
|
|
case 1:
|
|
var commandName = args[0];
|
|
if (!shell.ConsoleHost.RegisteredCommands.TryGetValue(commandName, out var cmd))
|
|
{
|
|
shell.WriteError(Loc.GetString("cmd-help-unknown", ("command", commandName)));
|
|
return;
|
|
}
|
|
|
|
shell.WriteLine(Loc.GetString("cmd-help-top", ("command", cmd.Command),
|
|
("description", cmd.Description)));
|
|
shell.WriteLine(cmd.Help);
|
|
break;
|
|
|
|
default:
|
|
shell.WriteError(Loc.GetString("cmd-help-invalid-args"));
|
|
break;
|
|
}
|
|
}
|
|
|
|
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
|
{
|
|
if (args.Length == 1)
|
|
{
|
|
var host = shell.ConsoleHost;
|
|
return CompletionResult.FromHintOptions(
|
|
host.RegisteredCommands.Values.OrderBy(c => c).Select(c => new CompletionOption(c.Command, c.Description)).ToArray(),
|
|
Loc.GetString("cmd-help-arg-cmdname"));
|
|
}
|
|
|
|
return CompletionResult.Empty;
|
|
}
|
|
}
|