Add logging for list encodings command and enhance UI formatting

This commit is contained in:
2025-08-17 02:23:50 +01:00
parent 5c9a0a55c0
commit 94800d9b63
3 changed files with 22 additions and 3 deletions

View File

@@ -6051,5 +6051,11 @@ namespace Aaru.Localization {
return ResourceManager.GetString("Title_Archive_Format", resourceCulture);
}
}
public static string List_encodings_command {
get {
return ResourceManager.GetString("List_encodings_command", resourceCulture);
}
}
}
}

View File

@@ -3102,4 +3102,7 @@ Do you want to continue?</value>
<data name="Title_Archive_Format" xml:space="preserve">
<value>Archive format</value>
</data>
<data name="List_encodings_command" xml:space="preserve">
<value>List encodings</value>
</data>
</root>

View File

@@ -36,6 +36,7 @@ using Aaru.CommonTypes.Enums;
using Aaru.Console;
using Aaru.Core;
using Aaru.Localization;
using Serilog;
using Spectre.Console;
using Spectre.Console.Cli;
@@ -55,6 +56,8 @@ sealed class ListEncodingsCommand : Command<ListEncodingsCommand.Settings>
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", settings.Debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", settings.Verbose);
Log.Information(UI.List_encodings_command);
var encodings = Encoding.GetEncodings()
.Select(info => new CommonEncodingInfo
{
@@ -71,11 +74,18 @@ sealed class ListEncodingsCommand : Command<ListEncodingsCommand.Settings>
}));
Table table = new();
table.AddColumn(UI.Title_Name);
table.AddColumn(UI.Title_Description);
table.AddColumn(new TableColumn(new Markup($"[bold][darkgreen]{UI.Title_Name}[/][/]").Centered()));
table.AddColumn(new TableColumn(new Markup($"[bold][slateblue1]{UI.Title_Description}[/][/]").Centered()));
table.Border(TableBorder.Rounded);
table.BorderColor(Color.Yellow);
foreach(CommonEncodingInfo info in encodings.OrderBy(t => t.DisplayName))
table.AddRow(info.Name, info.DisplayName);
{
table.AddRow($"[italic][darkgreen]{Markup.Escape(info.Name)}[/][/]",
$"[italic][slateblue1]{Markup.Escape(info.DisplayName)}[/][/]");
Log.Information("({Name}) - {DisplayName}", info.Name, info.DisplayName);
}
AnsiConsole.Write(table);