Files
RobustToolbox/Robust.Shared/Console/Commands/HelpCommand.cs
Moony 0e1328675c Toolshed (#4197)
* Saving work

* Move shit to engine

* lord

* merg

* awa

* bql is kill

* forgot the fucking bike rack

* bql is kill for real

* pjb will kill me

* aughfhbdj

* yo ho here we go on my way to the MINES

* a

* adgddf

* gdsgvfvxshngfgh

* b

* hfsjhghj

* hbfdjjh

* tf you mean i have to document it

* follow C# standards

* Assorted cleanup and documentation pass, minor bugfix in ValueRefParser.

* Start porting old commands, remove that pesky prefix in favor of integrating with the shell.

* Fix valueref up a bit, improve autocomplete for it.

* e

* Toolshed type system adventure.

* a log

* a

* a e i o u

* awa

* fix tests

* Arithmetic commands.

* a

* parse improvements

---------

Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
2023-08-02 16:06:16 -05:00

50 lines
1.6 KiB
C#

using System.Linq;
using Robust.Shared.Localization;
namespace Robust.Shared.Console.Commands;
internal sealed class HelpCommand : LocalizedCommands
{
public override string Command => "oldhelp";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
switch (args.Length)
{
case 0:
shell.WriteLine(Loc.GetString("cmd-oldhelp-no-args"));
break;
case 1:
var commandName = args[0];
if (!shell.ConsoleHost.AvailableCommands.TryGetValue(commandName, out var cmd))
{
shell.WriteError(Loc.GetString("cmd-oldhelp-unknown", ("command", commandName)));
return;
}
shell.WriteLine(Loc.GetString("cmd-oldhelp-top", ("command", cmd.Command),
("description", cmd.Description)));
shell.WriteLine(cmd.Help);
break;
default:
shell.WriteError(Loc.GetString("cmd-oldhelp-invalid-args"));
break;
}
}
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
{
var host = shell.ConsoleHost;
return CompletionResult.FromHintOptions(
host.AvailableCommands.Values.OrderBy(c => c.Command).Select(c => new CompletionOption(c.Command, c.Description)).ToArray(),
Loc.GetString("cmd-oldhelp-arg-cmdname"));
}
return CompletionResult.Empty;
}
}