From 38ef13749653c17d99f05dad414902e14ec16c72 Mon Sep 17 00:00:00 2001 From: glopesdev Date: Tue, 22 Sep 2026 10:21:40 +0100 Subject: [PATCH] Clean up option descriptions and unused code Improve wording in option and argument descriptions. Remove unused code and a redundant read of the device metadata file. --- .../Generate/GenerateRegisterMetadataCommand.cs | 2 +- src/Harp.Toolkit/Generate/GeneratorHelper.cs | 8 -------- src/Harp.Toolkit/Generate/IOMetadataPathOption.cs | 2 +- src/Harp.Toolkit/Generate/MetadataPathArgument.cs | 2 +- src/Harp.Toolkit/Verify/VerifyCommand.cs | 6 +++--- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/Harp.Toolkit/Generate/GenerateRegisterMetadataCommand.cs b/src/Harp.Toolkit/Generate/GenerateRegisterMetadataCommand.cs index 07e734f..f06c9d8 100644 --- a/src/Harp.Toolkit/Generate/GenerateRegisterMetadataCommand.cs +++ b/src/Harp.Toolkit/Generate/GenerateRegisterMetadataCommand.cs @@ -15,7 +15,7 @@ public GenerateRegisterMetadataCommand() Argument registerWorksheetPathArgument = ArgumentValidation.AcceptExistingOnly( new Argument("registers.xls") { - Description = "The path to the file describing the device registers.", + Description = "The path to the file that describes the device registers.", Arity = ArgumentArity.ExactlyOne }); diff --git a/src/Harp.Toolkit/Generate/GeneratorHelper.cs b/src/Harp.Toolkit/Generate/GeneratorHelper.cs index 9401dae..fb73563 100644 --- a/src/Harp.Toolkit/Generate/GeneratorHelper.cs +++ b/src/Harp.Toolkit/Generate/GeneratorHelper.cs @@ -1,18 +1,10 @@ using System.CodeDom.Compiler; using System.Text; -using Harp.Generators; namespace Harp.Toolkit.Generate; public static class GeneratorHelper { - public static IEnumerable> GetPortPinsOfType(IDictionary portPins) where T : PortPinInfo - { - return from item in portPins - where item.Value is T - select new KeyValuePair(item.Key, (T)item.Value); - } - public static bool AssertNoGeneratorErrors(CompilerErrorCollection errors) { if (errors.Count > 0) diff --git a/src/Harp.Toolkit/Generate/IOMetadataPathOption.cs b/src/Harp.Toolkit/Generate/IOMetadataPathOption.cs index 9fd7d98..c426885 100644 --- a/src/Harp.Toolkit/Generate/IOMetadataPathOption.cs +++ b/src/Harp.Toolkit/Generate/IOMetadataPathOption.cs @@ -8,7 +8,7 @@ public IOMetadataPathOption() : base("--ios") { OptionValidation.AcceptExistingOnly(this); - Description = "The path to the file describing the device IO pins."; + Description = "The path to the file that describes the device IO pins."; DefaultValueFactory = result => result.AcceptExistingOnly(new FileInfo("ios.yml")); } } diff --git a/src/Harp.Toolkit/Generate/MetadataPathArgument.cs b/src/Harp.Toolkit/Generate/MetadataPathArgument.cs index 4738850..7f690d2 100644 --- a/src/Harp.Toolkit/Generate/MetadataPathArgument.cs +++ b/src/Harp.Toolkit/Generate/MetadataPathArgument.cs @@ -8,7 +8,7 @@ public MetadataPathArgument() : base("metadata") { ArgumentValidation.AcceptExistingOnly(this); - Description = "The path to the file describing the device registers."; + Description = "The path to the file that describes the device registers."; DefaultValueFactory = result => result.AcceptExistingOnly(new FileInfo("device.yml")); Arity = ArgumentArity.ZeroOrOne; } diff --git a/src/Harp.Toolkit/Verify/VerifyCommand.cs b/src/Harp.Toolkit/Verify/VerifyCommand.cs index a123c44..7b86972 100644 --- a/src/Harp.Toolkit/Verify/VerifyCommand.cs +++ b/src/Harp.Toolkit/Verify/VerifyCommand.cs @@ -33,7 +33,7 @@ public VerifyCommand() Option ppsEventOption = new("--pps-event") { - Description = "Address of the register on the tested device (--port) that reports the incoming PPS pulse from the reference clock device. Enables the PPS alignment test, which also requires --clock-port.", + Description = "Address of the register on the tested device, given by --port, that reports the incoming PPS pulse from the reference clock device. Enables the PPS alignment test, which also requires --clock-port.", Required = false, }; @@ -51,7 +51,7 @@ public VerifyCommand() Option metadataOption = new("--metadata") { - Description = "The path to the file describing the device registers. Enables validation of the generated interface against a live read of every declared register, and cross-checks the WhoAmI, firmware and hardware versions.", + Description = "The path to the file that describes the device registers. Enables validation of the generated interface against a live read of every declared register, and cross-checks the WhoAmI, firmware and hardware versions.", Required = false, }; OptionValidation.AcceptExistingOnly(metadataOption); @@ -92,8 +92,8 @@ static async Task RunVerification(string portName, FileInfo? reportFile, bo if (metadataPath is not null) { AnsiConsole.Markup($"Loading device metadata from [bold]{metadataPath.FullName}[/]..."); - deviceMetadata = DeviceMetadata.Load(metadataPath.FullName); deviceRawYaml = await File.ReadAllTextAsync(metadataPath.FullName, cancellationToken); + deviceMetadata = DeviceMetadata.Parse(deviceRawYaml); AnsiConsole.MarkupLine($" [green]Done![/] ({deviceMetadata.Registers.Count} registers)"); }