mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* Console command completions v1.
I think it works™️
* Unify cvar commands
* Handle no-completions-at-all better.
* Don't crash if you tab complete while no completions available.
* Always show hints if available
* Properly null completion hint over the wire
* Unify help command, localize it.
* Clean up + localize cvar command.
* Remove debug logging
* List command unified & localized.
* Remove server completions debug logging
* Remote execute command.
Had to make everything async for this.
* Don't lower case enums or bools
Why
* GC commands converted and localized.
* Fix remote command completions.
Whoops
* Kick command completions
* lsasm unified & localized.
* Revert "Don't lower case enums or bools"
This reverts commit 2f825347c3.
* ToString gc_mode command enums instead of trying to fix Fluent.
Ah well.
* Unify szr_stats
* Unify log commands, completions
* Fix compile
* Improve completion with complex cases (quotes, escapes)
* Code cleanup, comments.
* Fix tab completion with empty arg ruining everything.
* Fix RegisteredCommand completions
* Add more complex completion options system.
* Refactor content directory entries into a proper resource manager API.
* Implement GetEntries for DirLoader
* Make type hint darker.
* Exec command autocomplete, pulled play global sound code out to engine.
67 lines
1.8 KiB
C#
67 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Robust.Shared.ContentPack;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.Shared.Console;
|
|
|
|
/// <summary>
|
|
/// Helpers for creating various completion results.
|
|
/// </summary>
|
|
public static class CompletionHelper
|
|
{
|
|
public static IEnumerable<CompletionOption> ContentFilePath(string arg, IResourceManager res)
|
|
{
|
|
var curPath = arg;
|
|
if (curPath == "")
|
|
curPath = "/";
|
|
|
|
var resPath = new ResourcePath(curPath);
|
|
|
|
if (!curPath.EndsWith("/"))
|
|
resPath = (resPath / "..").Clean();
|
|
|
|
var options = res.ContentGetDirectoryEntries(resPath)
|
|
.OrderBy(c => c)
|
|
.Select(c =>
|
|
{
|
|
var opt = (resPath / c).ToString();
|
|
|
|
if (c.EndsWith("/"))
|
|
return new CompletionOption(opt + "/", Flags: CompletionOptionFlags.PartialCompletion);
|
|
|
|
return new CompletionOption(opt);
|
|
});
|
|
|
|
return options;
|
|
}
|
|
|
|
public static IEnumerable<CompletionOption> UserFilePath(string arg, IWritableDirProvider provider)
|
|
{
|
|
var curPath = arg;
|
|
if (curPath == "")
|
|
curPath = "/";
|
|
|
|
var resPath = new ResourcePath(curPath);
|
|
|
|
if (!resPath.IsRooted)
|
|
return Enumerable.Empty<CompletionOption>();
|
|
|
|
if (!curPath.EndsWith("/"))
|
|
resPath = (resPath / "..").Clean();
|
|
|
|
var entries = provider.DirectoryEntries(resPath);
|
|
|
|
return entries
|
|
.Select(c =>
|
|
{
|
|
var full = resPath / c;
|
|
if (provider.IsDir(full))
|
|
return new CompletionOption($"{full}/", Flags: CompletionOptionFlags.PartialCompletion);
|
|
|
|
return new CompletionOption(full.ToString());
|
|
})
|
|
.OrderBy(c => c.Value);
|
|
}
|
|
}
|