diff --git a/Source/v2/Meadow.Cli/Commands/Current/File/FileListCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/File/FileListCommand.cs index 8358fb2e..4e32513a 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/File/FileListCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/File/FileListCommand.cs @@ -1,5 +1,6 @@ using CliFx.Attributes; using Microsoft.Extensions.Logging; +using System.Linq; namespace Meadow.CLI.Commands.DeviceManagement; @@ -8,6 +9,8 @@ public class FileListCommand : BaseDeviceCommand { public const int FileSystemBlockSize = 4096; + private const string MeadowRootFolder = "meadow0"; + [CommandOption("verbose", 'v', IsRequired = false)] public bool Verbose { get; init; } @@ -33,6 +36,14 @@ protected override async ValueTask ExecuteCommand() { Folder += "/"; } + if (Folder.StartsWith('/') == false) + { + Folder += "/"; + } + if (Folder.Contains(MeadowRootFolder) == false) + { + Folder += $"/{MeadowRootFolder}"; + } Logger?.LogInformation($"Getting file list from '{Folder}'..."); } @@ -41,7 +52,7 @@ protected override async ValueTask ExecuteCommand() Logger?.LogInformation($"Getting file list..."); } - var files = await connection.Device.GetFileList(Folder ?? "/meadow0/", Verbose, CancellationToken); + var files = await connection.Device.GetFileList(Folder ?? $"/{MeadowRootFolder}/", Verbose, CancellationToken); if (files == null || files.Length == 0) { @@ -49,6 +60,12 @@ protected override async ValueTask ExecuteCommand() } else { + files = files.OrderBy(file => + { + string prefix = file.IsDirectory ? "0" : "1"; + return $"{prefix}_{file.Name}"; + }).ToArray(); + if (Verbose) { var longestFileName = files.Select(x => x.Name.Length) @@ -93,7 +110,7 @@ protected override async ValueTask ExecuteCommand() { foreach (var file in files) { - Logger?.LogInformation(file.Name); + Logger?.LogInformation(file.Name + (file.IsDirectory?" [folder]":string.Empty)); } Logger?.LogInformation($"\t{files.Length} file(s)"); diff --git a/Source/v2/Meadow.Cli/Meadow.CLI.csproj b/Source/v2/Meadow.Cli/Meadow.CLI.csproj index 6641f0b4..5859f556 100644 --- a/Source/v2/Meadow.Cli/Meadow.CLI.csproj +++ b/Source/v2/Meadow.Cli/Meadow.CLI.csproj @@ -10,7 +10,7 @@ Wilderness Labs, Inc Wilderness Labs, Inc true - 2.0.6 + 2.0.7 AnyCPU http://developer.wildernesslabs.co/Meadow/Meadow.CLI/ https://github.com/WildernessLabs/Meadow.CLI diff --git a/Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs b/Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs index a35f254b..cb918ad9 100644 --- a/Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs +++ b/Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs @@ -6,6 +6,6 @@ namespace Meadow.CLI { public static class Constants { - public const string CLI_VERSION = "2.0.6.0"; + public const string CLI_VERSION = "2.0.7.0"; } } \ No newline at end of file