mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
`ResPath.RelativeTo()` now considers non-rooted paths relative to `.` This fixes some things like `MemoryContentRoot`'s `FindFiles()` implementation. Fix `IContentRoot.GetEntries()` default implementation (used by all content roots except `DirLoader`) not working at all. Made `ResourceManager.ContentGetDirectoryEntries()` report content root mount paths as directories. Added tests for all of the above.
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using Robust.Shared.ContentPack;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.Shared.Console.Commands;
|
|
|
|
public sealed class VfsListCommand : LocalizedCommands
|
|
{
|
|
[Dependency] private readonly IResourceManager _resourceManager = default!;
|
|
|
|
public override string Command => "vfs_ls";
|
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length > 1)
|
|
{
|
|
shell.WriteError(LocalizationManager.GetString("cmd-vfs_ls-err-args"));
|
|
return;
|
|
}
|
|
|
|
var entries = _resourceManager.ContentGetDirectoryEntries(new ResPath(args[0]));
|
|
foreach (var entry in entries)
|
|
{
|
|
shell.WriteLine(entry);
|
|
}
|
|
}
|
|
|
|
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
|
{
|
|
if (args.Length == 1)
|
|
{
|
|
var opts = CompletionHelper.ContentDirPath(args[0], _resourceManager);
|
|
return CompletionResult.FromHintOptions(opts, LocalizationManager.GetString("cmd-vfs_ls-hint-path"));
|
|
}
|
|
|
|
return CompletionResult.Empty;
|
|
}
|
|
}
|