Toolshed (#17895)
* ogh * i should save my work * ogh * hhcdfhjbghshbxdfhghshc - lots of bugs in parsing still - invocation is a stub * expr parsing works * awawa * Saving work * Improve APIs a bit all around, add shortcuts. * awa * awa * AAAAAA * save work * Move shit to engine * lord * bql is kill * forgot the fucking bike rack * bql is kill for real * pjb will kill me * aughfhbdj * adgddf * gdsgvfvxshngfgh * b * hfsjhghj * a * 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. * bw * Fix valueref up a bit, improve autocomplete for it. * awa * fix tests * git shut up * Arithmetic commands. * parse improvements * Update engine. --------- Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
This commit is contained in:
49
Content.Server/Administration/Toolshed/SolutionCommand.cs
Normal file
49
Content.Server/Administration/Toolshed/SolutionCommand.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Robust.Shared.Toolshed;
|
||||
using Robust.Shared.Toolshed.Syntax;
|
||||
|
||||
namespace Content.Server.Administration.Toolshed;
|
||||
|
||||
[ToolshedCommand, AdminCommand(AdminFlags.Debug)]
|
||||
public sealed class SolutionCommand : ToolshedCommand
|
||||
{
|
||||
private SolutionContainerSystem? _solutionContainer;
|
||||
|
||||
[CommandImplementation("get")]
|
||||
public SolutionRef? Get(
|
||||
[CommandInvocationContext] IInvocationContext ctx,
|
||||
[PipedArgument] EntityUid input,
|
||||
[CommandArgument] ValueRef<string> name
|
||||
)
|
||||
{
|
||||
_solutionContainer ??= GetSys<SolutionContainerSystem>();
|
||||
|
||||
_solutionContainer.TryGetSolution(input, name.Evaluate(ctx)!, out var solution);
|
||||
|
||||
if (solution is not null)
|
||||
return new SolutionRef(input, solution);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
[CommandImplementation("get")]
|
||||
public IEnumerable<SolutionRef> Get(
|
||||
[CommandInvocationContext] IInvocationContext ctx,
|
||||
[PipedArgument] IEnumerable<EntityUid> input,
|
||||
[CommandArgument] ValueRef<string> name
|
||||
)
|
||||
{
|
||||
return input.Select(x => Get(ctx, x, name)).Where(x => x is not null).Cast<SolutionRef>();
|
||||
}
|
||||
}
|
||||
|
||||
public readonly record struct SolutionRef(EntityUid Owner, Solution Solution)
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Owner} {Solution}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user