Toolshed Rejig (#5455)

* Toolshed Rejig

* shorten hint string

* Try fix conflicts. Ill make with work later

* bodge

* Fix ProtoIdTypeParser assert

* comment

* AllEntities

* Remove more linq from WhereCommand

* better help strings

* Add ContainsCommand

* loc strings

* Add contains command description

* Add $self variable

* Errors for writing to readonly variables

* A
This commit is contained in:
Leon Friedrich
2024-12-21 17:49:11 +11:00
committed by GitHub
parent 6247be2c84
commit 9af119f57a
134 changed files with 5129 additions and 3027 deletions

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@@ -11,7 +10,6 @@ using Robust.Shared.Network;
using Robust.Shared.Network.Messages;
using Robust.Shared.Player;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Syntax;
using Robust.Shared.Utility;
namespace Robust.Server.Console
@@ -162,8 +160,8 @@ namespace Robust.Server.Console
{
var message = new MsgConCmdReg();
var toolshedCommands = _toolshed.DefaultEnvironment.AllCommands().ToArray();
message.Commands = new List<MsgConCmdReg.Command>(AvailableCommands.Count + toolshedCommands.Length);
var toolshedCommands = _toolshed.DefaultEnvironment.AllCommands();
message.Commands = new List<MsgConCmdReg.Command>(AvailableCommands.Count + toolshedCommands.Count);
var commands = new HashSet<string>();
foreach (var command in AvailableCommands.Values)
@@ -240,20 +238,15 @@ namespace Robust.Server.Console
if ((result == null) || message.Args.Length <= 1)
{
var parser = new ParserContext(message.ArgString, _toolshed);
CommandRun.TryParse(true, parser, null, null, false, out _, out var completions, out _);
if (completions == null)
{
var shedRes = _toolshed.GetCompletions(shell, message.ArgString);
if (shedRes == null)
goto done;
}
var (shedRes, _) = await completions.Value;
IEnumerable<CompletionOption> options = result?.Options ?? Array.Empty<CompletionOption>();
if (shedRes != null)
options = options.Concat(shedRes.Options);
options = options.Concat(shedRes.Options);
var hints = result?.Hint ?? shedRes?.Hint;
var hints = result?.Hint ?? shedRes.Hint;
result = new CompletionResult(options.ToArray(), hints);
}

View File

@@ -24,7 +24,7 @@ public sealed class PlayerCommand : ToolshedCommand
=> _playerManager.Sessions;
[CommandImplementation("self")]
public ICommonSession Self([CommandInvocationContext] IInvocationContext ctx)
public ICommonSession Self(IInvocationContext ctx)
{
if (ctx.Session is null)
{
@@ -35,10 +35,7 @@ public sealed class PlayerCommand : ToolshedCommand
}
[CommandImplementation("imm")]
public ICommonSession Immediate(
[CommandInvocationContext] IInvocationContext ctx,
[CommandArgument] string username
)
public ICommonSession Immediate(IInvocationContext ctx, string username)
{
_playerManager.TryGetSessionByUsername(username, out var session);
@@ -71,7 +68,7 @@ public sealed class PlayerCommand : ToolshedCommand
}
[CommandImplementation("entity")]
public EntityUid GetPlayerEntity([CommandInvocationContext] IInvocationContext ctx, [CommandArgument] string username)
public EntityUid GetPlayerEntity(IInvocationContext ctx, string username)
{
return GetPlayerEntity(Immediate(ctx, username));
}