mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* Renamed shared ICommand to IConsoleCommand. * Lots of refactoring into a shared context. * Removed ICommonSession from server concmd Execute. * Added argStr parameter to concmd execute. * The execute function of client concmds now returns void, use the new shell.RemoteExecuteCommand function to forward commands. # Conflicts: # Robust.Client/Console/Commands/Debug.cs * Finally move shells and commands into shared. * Console commands can now be registered directly without a class in a shared context. * Pulled up ConsoleHost and Console shell into a shared context. * Pulled up half the functions of ConsoleHost into a shared context. * Repair rebase damage. * Make LoadConsoleCommands function not remove any previously registered commands.
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using System.Linq;
|
|
using System.Text;
|
|
using Robust.Server.Interfaces.Player;
|
|
using Robust.Shared.Console;
|
|
|
|
namespace Robust.Server.Console.Commands
|
|
{
|
|
public 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);
|
|
}
|
|
}
|
|
}
|