adds autocomplete to the crew manifest command (#11829)

This commit is contained in:
Flipp Syder
2022-10-10 22:33:48 -07:00
committed by GitHub
parent 1468ae785b
commit 9f9691511a

View File

@@ -1,3 +1,4 @@
using System.Linq;
using Content.Server.Administration;
using Content.Server.EUI;
using Content.Server.GameTicking;
@@ -232,6 +233,13 @@ public sealed class CrewManifestCommand : IConsoleCommand
public string Description => "Opens the crew manifest for the given station.";
public string Help => $"Usage: {Command} <entity uid>";
[Dependency] private readonly IEntityManager _entityManager = default!;
public CrewManifestCommand()
{
IoCManager.InjectDependencies(this);
}
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
@@ -240,8 +248,6 @@ public sealed class CrewManifestCommand : IConsoleCommand
return;
}
var entMan = IoCManager.Resolve<IEntityManager>();
if (!EntityUid.TryParse(args[0], out var uid))
{
shell.WriteLine($"{args[0]} is not a valid entity UID.");
@@ -254,8 +260,28 @@ public sealed class CrewManifestCommand : IConsoleCommand
return;
}
var crewManifestSystem = entMan.EntitySysManager.GetEntitySystem<CrewManifestSystem>();
var crewManifestSystem = _entityManager.System<CrewManifestSystem>();
crewManifestSystem.OpenEui(uid, session);
}
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length != 1)
{
return CompletionResult.Empty;
}
var stations = _entityManager
.System<StationSystem>()
.Stations
.Select(station =>
{
var meta = _entityManager.GetComponent<MetaDataComponent>(station);
return new CompletionOption(station.ToString(), meta.EntityName);
});
return CompletionResult.FromHintOptions(stations, null);
}
}