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.
46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using System.Linq;
|
|
using System.Text;
|
|
using Robust.Shared.Localization;
|
|
|
|
namespace Robust.Shared.Console.Commands;
|
|
|
|
internal sealed class ListCommands : IConsoleCommand
|
|
{
|
|
public string Command => "list";
|
|
|
|
public string Description => Loc.GetString("cmd-list-desc");
|
|
|
|
public string Help => Loc.GetString("cmd-list-help");
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
var filter = "";
|
|
if (args.Length == 1)
|
|
filter = args[0];
|
|
|
|
var host = (IConsoleHostInternal)shell.ConsoleHost;
|
|
|
|
var builder = new StringBuilder(Loc.GetString("cmd-list-heading"));
|
|
foreach (var command in host.RegisteredCommands.Values
|
|
.Where(p => p.Command.Contains(filter))
|
|
.OrderBy(c => c.Command))
|
|
{
|
|
//TODO: Make this actually check permissions.
|
|
|
|
var side = host.IsCmdServer(command) ? "S" : "C";
|
|
builder.AppendLine($"{side} {command.Command,-32}{command.Description}");
|
|
}
|
|
|
|
var message = builder.ToString().Trim(' ', '\n');
|
|
shell.WriteLine(message);
|
|
}
|
|
|
|
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
|
{
|
|
if (args.Length == 1)
|
|
return CompletionResult.FromHint(Loc.GetString("cmd-list-arg-filter"));
|
|
|
|
return CompletionResult.Empty;
|
|
}
|
|
}
|