diff --git a/Content.Server/Administration/Commands/Station/AdjustStationJobCommand.cs b/Content.Server/Administration/Commands/Station/AdjustStationJobCommand.cs index 1bb0668e52..3af9ed6b26 100644 --- a/Content.Server/Administration/Commands/Station/AdjustStationJobCommand.cs +++ b/Content.Server/Administration/Commands/Station/AdjustStationJobCommand.cs @@ -1,3 +1,4 @@ +using Content.Server.Commands; using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Shared.Administration; @@ -58,4 +59,26 @@ public sealed class AdjustStationJobCommand : IConsoleCommand stationJobs.TrySetJobSlot(station, job, amount, true); } + + public CompletionResult GetCompletion(IConsoleShell shell, string[] args) + { + if (args.Length == 1) + { + var options = ContentCompletionHelper.StationIds(_entityManager); + return CompletionResult.FromHintOptions(options, ""); + } + + if (args.Length == 2) + { + var options = CompletionHelper.PrototypeIDs(); + return CompletionResult.FromHintOptions(options, ""); + } + + if (args.Length == 3) + { + return CompletionResult.FromHint(""); + } + + return CompletionResult.Empty; + } } diff --git a/Content.Server/Administration/Commands/Station/ListStationJobsCommand.cs b/Content.Server/Administration/Commands/Station/ListStationJobsCommand.cs index 1b00ac48d0..53a902ec29 100644 --- a/Content.Server/Administration/Commands/Station/ListStationJobsCommand.cs +++ b/Content.Server/Administration/Commands/Station/ListStationJobsCommand.cs @@ -1,3 +1,4 @@ +using Content.Server.Commands; using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Shared.Administration; @@ -40,4 +41,15 @@ public sealed class ListStationJobsCommand : IConsoleCommand shell.WriteLine($"{job}: {amountText}"); } } + + public CompletionResult GetCompletion(IConsoleShell shell, string[] args) + { + if (args.Length == 1) + { + var options = ContentCompletionHelper.StationIds(_entityManager); + return CompletionResult.FromHintOptions(options, ""); + } + + return CompletionResult.Empty; + } } diff --git a/Content.Server/Administration/Commands/Station/RenameStationCommand.cs b/Content.Server/Administration/Commands/Station/RenameStationCommand.cs index 78428841ea..10df9049fd 100644 --- a/Content.Server/Administration/Commands/Station/RenameStationCommand.cs +++ b/Content.Server/Administration/Commands/Station/RenameStationCommand.cs @@ -1,3 +1,4 @@ +using Content.Server.Commands; using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Shared.Administration; @@ -27,7 +28,7 @@ public sealed class RenameStationCommand : IConsoleCommand var stationSystem = _entSysManager.GetEntitySystem(); - if (!EntityUid.TryParse(args[0], out var station) || _entityManager.HasComponent(station)) + if (!EntityUid.TryParse(args[0], out var station) || !_entityManager.HasComponent(station)) { shell.WriteError(Loc.GetString("shell-argument-station-id-invalid", ("index", 1))); return; @@ -35,4 +36,20 @@ public sealed class RenameStationCommand : IConsoleCommand stationSystem.RenameStation(station, args[1]); } + + public CompletionResult GetCompletion(IConsoleShell shell, string[] args) + { + if (args.Length == 1) + { + var options = ContentCompletionHelper.StationIds(_entityManager); + return CompletionResult.FromHintOptions(options, ""); + } + + if (args.Length == 2) + { + return CompletionResult.FromHint(""); + } + + return CompletionResult.Empty; + } } diff --git a/Content.Server/Commands/ContentCompletionHelper.cs b/Content.Server/Commands/ContentCompletionHelper.cs new file mode 100644 index 0000000000..f843d84a62 --- /dev/null +++ b/Content.Server/Commands/ContentCompletionHelper.cs @@ -0,0 +1,22 @@ +using Content.Server.Station.Components; +using Robust.Shared.Console; + +namespace Content.Server.Commands; + +/// +/// Helper functions for programming console command completions. +/// +public static class ContentCompletionHelper +{ + /// + /// Return all stations, with their ID as value and name as hint. + /// + public static IEnumerable StationIds(IEntityManager entityManager) + { + var query = entityManager.EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out _, out var metaData)) + { + yield return new CompletionOption(uid.ToString(), metaData.EntityName); + } + } +}