mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-03 18:47:10 +02:00
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using System.Linq;
|
|
using System.Text;
|
|
using Robust.Shared.Console;
|
|
|
|
namespace Robust.Server.Console.Commands
|
|
{
|
|
public sealed class ListCommands : IConsoleCommand
|
|
{
|
|
public string Command => "list";
|
|
|
|
public string Description => "Outputs a list of all commands which are currently available to you. " +
|
|
"If a filter is provided, " +
|
|
"only commands that contain the given string in their name will be listed.";
|
|
|
|
public string Help => "Usage: list [filter]";
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
var filter = "";
|
|
if (args.Length == 1)
|
|
{
|
|
filter = args[0];
|
|
}
|
|
|
|
var builder = new StringBuilder("SIDE NAME DESC\n-------------------------\n");
|
|
foreach (var command in shell.ConsoleHost.RegisteredCommands.Values
|
|
.Where(p => p.Command.Contains(filter))
|
|
.OrderBy(c => c.Command))
|
|
{
|
|
//TODO: Make this actually check permissions.
|
|
|
|
builder.AppendLine($"S {command.Command,-16}{command.Description}");
|
|
}
|
|
|
|
var message = builder.ToString().Trim(' ', '\n');
|
|
shell.WriteLine(message);
|
|
}
|
|
}
|
|
}
|