From 4f9f9e5942fbb913d5bdd01ebb5a14fb76af33c9 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Fri, 27 May 2022 02:19:31 +0200 Subject: [PATCH] Completions for the warp command (#8470) --- .../Administration/Commands/WarpCommand.cs | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/Content.Server/Administration/Commands/WarpCommand.cs b/Content.Server/Administration/Commands/WarpCommand.cs index 69ad871f78..11f62216a9 100644 --- a/Content.Server/Administration/Commands/WarpCommand.cs +++ b/Content.Server/Administration/Commands/WarpCommand.cs @@ -38,12 +38,7 @@ namespace Content.Server.Administration.Commands var location = args[0]; if (location == "?") { - var locations = string.Join(", ", - entMan.EntityQuery(true) - .Select(p => p.Location) - .Where(p => p != null) - .OrderBy(p => p) - .Distinct()); + var locations = string.Join(", ", GetWarpPointNames(entMan)); shell.WriteLine(locations); } @@ -121,5 +116,27 @@ namespace Content.Server.Administration.Commands } } } + + private static IEnumerable GetWarpPointNames(IEntityManager entMan) + { + return entMan.EntityQuery(true) + .Select(p => p.Location) + .Where(p => p != null) + .OrderBy(p => p) + .Distinct()!; + } + + public CompletionResult GetCompletion(IConsoleShell shell, string[] args) + { + if (args.Length == 1) + { + var ent = IoCManager.Resolve(); + var options = new[] { "?" }.Concat(GetWarpPointNames(ent)); + + return CompletionResult.FromHintOptions(options, ""); + } + + return CompletionResult.Empty; + } } }