Implement the ls command

This commit is contained in:
Jet the Hawk 2023-02-21 18:44:37 -05:00
parent 72f01b1342
commit 65459cd36c

View file

@ -2,6 +2,7 @@
using Architecture;
using UnityEngine;
using Utility;
namespace UI.ScriptableCommands
{
@ -11,7 +12,27 @@ namespace UI.ScriptableCommands
/// <inheritdoc />
protected override void OnExecute()
{
Console.WriteLine("TBD");
// TODO: Listing directories specified in arguments
// TODO: Colorful output
// TODO: Different output styles
// error out if the current directory doesn't exist
if (!FileSystem.DirectoryExists(CurrentWorkingDirectory))
{
Console.WriteLine($"ls: {CurrentWorkingDirectory}: Directory not found.");
return;
}
foreach (string directory in FileSystem.GetDirectories(CurrentWorkingDirectory))
{
string filename = PathUtility.GetFileName(directory);
Console.WriteLine(filename);
}
foreach (string directory in FileSystem.GetFiles(CurrentWorkingDirectory))
{
string filename = PathUtility.GetFileName(directory);
Console.WriteLine(filename);
}
}
}
}