Files
tbd-station-14/Content.Server/Toolshed/Commands/AdminDebug/ACmdCommand.cs
Moony 3d3c9e3348 Toolshed part 2 (#18997)
* fixe

* Save work.

* Rune-aware parser.

* oogh

* pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests pass tests

* Publicizes a lot of common generic commands, so custom toolshed envs can include them.

* i think i might implode

* Tests.

* a

* b

* awa

---------

Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
2023-08-23 16:03:41 -05:00

35 lines
1.1 KiB
C#

using Content.Server.Administration;
using Content.Server.Administration.Managers;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Syntax;
namespace Content.Server.Toolshed.Commands.AdminDebug;
[ToolshedCommand, AdminCommand(AdminFlags.Debug)]
public sealed class ACmdCommand : ToolshedCommand
{
[Dependency] private readonly IAdminManager _adminManager = default!;
[CommandImplementation("perms")]
public AdminFlags[]? Perms([PipedArgument] CommandSpec command)
{
var res = _adminManager.TryGetCommandFlags(command, out var flags);
if (res)
flags ??= Array.Empty<AdminFlags>();
return flags;
}
[CommandImplementation("caninvoke")]
public bool CanInvoke(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] CommandSpec command,
[CommandArgument] ValueRef<IPlayerSession> player
)
{
// Deliberately discard the error.
return ((IPermissionController) _adminManager).CheckInvokable(command, player.Evaluate(ctx), out var err);
}
}