From 26d8ba1877f44de000f68134abd857940dc7a524 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 17 Aug 2025 03:51:30 +0100 Subject: [PATCH] Add logging and UI enhancements for list devices command --- Aaru.Localization/UI.Designer.cs | 6 +++++ Aaru.Localization/UI.resx | 3 +++ Aaru/Commands/Device/List.cs | 40 ++++++++++++++++++++++---------- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/Aaru.Localization/UI.Designer.cs b/Aaru.Localization/UI.Designer.cs index 894bbe32e..51d1b4323 100644 --- a/Aaru.Localization/UI.Designer.cs +++ b/Aaru.Localization/UI.Designer.cs @@ -6069,5 +6069,11 @@ namespace Aaru.Localization { return ResourceManager.GetString("Database_statistics_command", resourceCulture); } } + + public static string List_devices_command { + get { + return ResourceManager.GetString("List_devices_command", resourceCulture); + } + } } } diff --git a/Aaru.Localization/UI.resx b/Aaru.Localization/UI.resx index efeb6f9ea..1a4878d99 100644 --- a/Aaru.Localization/UI.resx +++ b/Aaru.Localization/UI.resx @@ -3111,4 +3111,7 @@ Do you want to continue? Database statistics: + + List devices + \ No newline at end of file diff --git a/Aaru/Commands/Device/List.cs b/Aaru/Commands/Device/List.cs index e426ecf9f..19710c47f 100644 --- a/Aaru/Commands/Device/List.cs +++ b/Aaru/Commands/Device/List.cs @@ -38,6 +38,7 @@ using Aaru.Core; using Aaru.Devices; using Aaru.Localization; using JetBrains.Annotations; +using Serilog; using Spectre.Console; using Spectre.Console.Cli; @@ -57,6 +58,8 @@ sealed class ListDevicesCommand : Command AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", settings.Debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", settings.Verbose); + Log.Information(UI.List_devices_command); + DeviceInfo[] devices = Devices.Device.ListDevices(out bool isRemote, out string serverApplication, out string serverVersion, @@ -75,25 +78,38 @@ sealed class ListDevicesCommand : Command } if(devices == null || devices.Length == 0) + { AaruConsole.WriteLine(UI.No_known_devices_attached); + Log.Information(UI.No_known_devices_attached); + } else { Table table = new(); - table.AddColumn(UI.Path); - table.AddColumn(UI.Title_Vendor); - table.AddColumn(UI.Title_Model); - table.AddColumn(UI.Serial); - table.AddColumn(UI.Title_Bus); - table.AddColumn(UI.Supported_Question); + table.AddColumn($"[bold][olive]{UI.Path}[/][/]"); + table.AddColumn($"[bold][blue]{UI.Title_Vendor}[/][/]"); + table.AddColumn($"[bold][purple]{UI.Title_Model}[/][/]"); + table.AddColumn($"[bold][aqua]{UI.Serial}[/][/]"); + table.AddColumn($"[bold][rosybrown]{UI.Title_Bus}[/][/]"); + table.AddColumn($"[bold][green]{UI.Supported_Question}[/][/]"); + table.Border(TableBorder.Rounded); + table.BorderColor(Color.Yellow); foreach(DeviceInfo dev in devices.OrderBy(d => d.Path)) { - table.AddRow(Markup.Escape(dev.Path ?? ""), - Markup.Escape(dev.Vendor ?? ""), - Markup.Escape(dev.Model ?? ""), - Markup.Escape(dev.Serial ?? ""), - Markup.Escape(dev.Bus ?? ""), - dev.Supported ? "[green]✓[/]" : "[red]✗[/]"); + table.AddRow($"[italic][olive]{Markup.Escape(dev.Path ?? "")}[/][/]", + $"[italic][blue]{Markup.Escape(dev.Vendor ?? "")}[/][/]", + $"[italic][purple]{Markup.Escape(dev.Model ?? "")}[/][/]", + $"[italic][aqua]{Markup.Escape(dev.Serial ?? "")}[/][/]", + $"[italic][rosybrown]{Markup.Escape(dev.Bus ?? "")}[/][/]", + $"[italic]{(dev.Supported ? "[green]✓[/]" : "[red]✗[/]")}[/]"); + + Log.Information("Path: {Path}, Vendor: {Vendor}, Model: {Model}, Serial: {Serial}, Bus: {Bus}, Supported: {Supported}", + dev.Path, + dev.Vendor, + dev.Model, + dev.Serial, + dev.Bus, + dev.Supported); } AnsiConsole.Write(table);