diff --git a/Aaru/Aaru.csproj b/Aaru/Aaru.csproj index 4c77317ac..8c696f99e 100644 --- a/Aaru/Aaru.csproj +++ b/Aaru/Aaru.csproj @@ -52,63 +52,63 @@ false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - + + + - - + + - - + + I @@ -129,28 +129,28 @@ Exception - - - - + + + + _ m_ - + _ m_ - - - - - + + + + + T @@ -158,15 +158,15 @@ - - - + + + - + @@ -190,8 +190,8 @@ - - + + @@ -216,33 +216,34 @@ - + - + - - - - - - - + + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - + + + + + + + + - + -dbg diff --git a/Aaru/Commands/Archive/Info.cs b/Aaru/Commands/Archive/Info.cs index 721f2ce2c..4d2ef3bb1 100644 --- a/Aaru/Commands/Archive/Info.cs +++ b/Aaru/Commands/Archive/Info.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands.Archive; using System; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using Aaru.CommonTypes.Enums; using Aaru.Console; using Aaru.Core; diff --git a/Aaru/Commands/Configure.cs b/Aaru/Commands/Configure.cs index 42f54adab..528546203 100644 --- a/Aaru/Commands/Configure.cs +++ b/Aaru/Commands/Configure.cs @@ -34,7 +34,7 @@ namespace Aaru.Commands; using System; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using Aaru.CommonTypes.Enums; using Aaru.Console; using Aaru.Settings; diff --git a/Aaru/Commands/Database/Statistics.cs b/Aaru/Commands/Database/Statistics.cs index 64b5f6680..1bb0fa3a3 100644 --- a/Aaru/Commands/Database/Statistics.cs +++ b/Aaru/Commands/Database/Statistics.cs @@ -33,7 +33,7 @@ namespace Aaru.Commands.Database; using System; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.Linq; using Aaru.CommonTypes.Enums; using Aaru.Console; diff --git a/Aaru/Commands/Database/Update.cs b/Aaru/Commands/Database/Update.cs index c8ee90bfc..65c83f89f 100644 --- a/Aaru/Commands/Database/Update.cs +++ b/Aaru/Commands/Database/Update.cs @@ -34,7 +34,7 @@ namespace Aaru.Commands.Database; using System; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.Diagnostics; using System.IO; using Aaru.CommonTypes.Enums; @@ -53,17 +53,8 @@ sealed class UpdateCommand : Command { _mainDbUpdate = mainDbUpdate; - Add(new Option("--clear", "Clear existing main database.") - { - Argument = new Argument(() => false), - Required = false - }); - - Add(new Option("--clear-all", "Clear existing main and local database.") - { - Argument = new Argument(() => false), - Required = false - }); + Add(new Option("--clear", () => false, "Clear existing main database.")); + Add(new Option("--clear-all", () => false, "Clear existing main and local database.")); Handler = CommandHandler.Create((Func)Invoke); } diff --git a/Aaru/Commands/Device/DeviceReport.cs b/Aaru/Commands/Device/DeviceReport.cs index 7cad63a33..a2ac316ef 100644 --- a/Aaru/Commands/Device/DeviceReport.cs +++ b/Aaru/Commands/Device/DeviceReport.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands.Device; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.IO; using System.Linq; using System.Threading; @@ -70,14 +70,10 @@ sealed class DeviceReportCommand : Command Name = "device-path" }); - Add(new Option(new[] - { - "--trap-disc", "-t" - }, "Does a device report using a trap disc.") - { - Argument = new Argument(() => false), - Required = false - }); + Add(new Option(new[] + { + "--trap-disc", "-t" + }, () => false, "Does a device report using a trap disc.")); Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); } diff --git a/Aaru/Commands/Device/Info.cs b/Aaru/Commands/Device/Info.cs index 3bd700045..56a22215c 100644 --- a/Aaru/Commands/Device/Info.cs +++ b/Aaru/Commands/Device/Info.cs @@ -36,7 +36,7 @@ namespace Aaru.Commands.Device; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.Linq; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -67,14 +67,10 @@ sealed class DeviceInfoCommand : Command { public DeviceInfoCommand() : base("info", "Gets information about a device.") { - Add(new Option(new[] - { - "--output-prefix", "-w" - }, "Prefix for saving binary information from device.") - { - Argument = new Argument(() => null), - Required = false - }); + Add(new Option(new[] + { + "--output-prefix", "-w" + }, () => null, "Prefix for saving binary information from device.")); AddArgument(new Argument { diff --git a/Aaru/Commands/Device/List.cs b/Aaru/Commands/Device/List.cs index 0d9f3e5f0..20211845d 100644 --- a/Aaru/Commands/Device/List.cs +++ b/Aaru/Commands/Device/List.cs @@ -34,7 +34,7 @@ namespace Aaru.Commands.Device; using System; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.Linq; using Aaru.CommonTypes.Enums; using Aaru.Console; diff --git a/Aaru/Commands/Filesystem/ExtractFiles.cs b/Aaru/Commands/Filesystem/ExtractFiles.cs index 853a8eda7..6ed08d623 100644 --- a/Aaru/Commands/Filesystem/ExtractFiles.cs +++ b/Aaru/Commands/Filesystem/ExtractFiles.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands.Filesystem; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.IO; using System.Text; using Aaru.CommonTypes; @@ -54,41 +54,25 @@ sealed class ExtractFilesCommand : Command public ExtractFilesCommand() : base("extract", "Extracts all files in disc image.") { - Add(new Option(new[] - { - "--encoding", "-e" - }, "Name of character encoding to use.") - { - Argument = new Argument(() => null), - Required = false - }); + Add(new Option(new[] + { + "--encoding", "-e" + }, () => null, "Name of character encoding to use.")); - Add(new Option(new[] - { - "--options", "-O" - }, "Comma separated name=value pairs of options to pass to filesystem plugin.") - { - Argument = new Argument(() => null), - Required = false - }); + Add(new Option(new[] + { + "--options", "-O" + }, () => null, "Comma separated name=value pairs of options to pass to filesystem plugin.")); - Add(new Option(new[] - { - "--xattrs", "-x" - }, "Extract extended attributes if present.") - { - Argument = new Argument(() => false), - Required = false - }); + Add(new Option(new[] + { + "--xattrs", "-x" + }, () => false, "Extract extended attributes if present.")); - Add(new Option(new[] - { - "--namespace", "-n" - }, "Namespace to use for filenames.") - { - Argument = new Argument(() => null), - Required = false - }); + Add(new Option(new[] + { + "--namespace", "-n" + }, () => null, "Namespace to use for filenames.")); AddArgument(new Argument { diff --git a/Aaru/Commands/Filesystem/Info.cs b/Aaru/Commands/Filesystem/Info.cs index dcf00828d..9fb44235e 100644 --- a/Aaru/Commands/Filesystem/Info.cs +++ b/Aaru/Commands/Filesystem/Info.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands.Filesystem; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -49,32 +49,20 @@ sealed class FilesystemInfoCommand : Command public FilesystemInfoCommand() : base("info", "Opens a disc image and prints info on the found partitions and/or filesystems.") { - Add(new Option(new[] - { - "--encoding", "-e" - }, "Name of character encoding to use.") - { - Argument = new Argument(() => null), - Required = false - }); + Add(new Option(new[] + { + "--encoding", "-e" + }, () => null, "Name of character encoding to use.")); - Add(new Option(new[] - { - "--filesystems", "-f" - }, "Searches and prints information about filesystems.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--filesystems", "-f" + }, () => true, "Searches and prints information about filesystems.")); - Add(new Option(new[] - { - "--partitions", "-p" - }, "Searches and interprets partitions.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--partitions", "-p" + }, () => true, "Searches and interprets partitions.")); AddArgument(new Argument { diff --git a/Aaru/Commands/Filesystem/Ls.cs b/Aaru/Commands/Filesystem/Ls.cs index 4559f883b..ade13b96c 100644 --- a/Aaru/Commands/Filesystem/Ls.cs +++ b/Aaru/Commands/Filesystem/Ls.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands.Filesystem; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.Linq; using System.Text; using Aaru.CommonTypes; @@ -53,41 +53,25 @@ sealed class LsCommand : Command { AddAlias("ls"); - Add(new Option(new[] - { - "--encoding", "-e" - }, "Name of character encoding to use.") - { - Argument = new Argument(() => null), - Required = false - }); + Add(new Option(new[] + { + "--encoding", "-e" + }, () => null, "Name of character encoding to use.")); - Add(new Option(new[] - { - "--long-format", "-l" - }, "Uses long format.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--long-format", "-l" + }, () => true, "Uses long format.")); - Add(new Option(new[] - { - "--options", "-O" - }, "Comma separated name=value pairs of options to pass to filesystem plugin.") - { - Argument = new Argument(() => null), - Required = false - }); + Add(new Option(new[] + { + "--options", "-O" + }, () => null, "Comma separated name=value pairs of options to pass to filesystem plugin.")); - Add(new Option(new[] - { - "--namespace", "-n" - }, "Namespace to use for filenames.") - { - Argument = new Argument(() => null), - Required = false - }); + Add(new Option(new[] + { + "--namespace", "-n" + }, () => null, "Namespace to use for filenames.")); AddArgument(new Argument { diff --git a/Aaru/Commands/Filesystem/Options.cs b/Aaru/Commands/Filesystem/Options.cs index 73e07b440..4f900cf99 100644 --- a/Aaru/Commands/Filesystem/Options.cs +++ b/Aaru/Commands/Filesystem/Options.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands.Filesystem; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.Linq; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; diff --git a/Aaru/Commands/Formats.cs b/Aaru/Commands/Formats.cs index d25544bb6..86bdec8eb 100644 --- a/Aaru/Commands/Formats.cs +++ b/Aaru/Commands/Formats.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.Linq; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; diff --git a/Aaru/Commands/Image/Checksum.cs b/Aaru/Commands/Image/Checksum.cs index 8b90687f2..732a610d0 100644 --- a/Aaru/Commands/Image/Checksum.cs +++ b/Aaru/Commands/Image/Checksum.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands.Image; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; @@ -57,110 +57,50 @@ sealed class ChecksumCommand : Command { AddAlias("chk"); - Add(new Option(new[] - { - "--adler32", "-a" - }, "Calculates Adler32.") - { - Argument = new Argument(() => false), - Required = false - }); - - Add(new Option("--crc16", "Calculates CRC16.") + Add(new Option(new[] { - Argument = new Argument(() => true), - Required = false - }); + "--adler32", "-a" + }, () => false, "Calculates Adler32.")); - Add(new Option(new[] - { - "--crc32", "-c" - }, "Calculates CRC32.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option("--crc16", () => true, "Calculates CRC16.")); - Add(new Option("--crc64", "Calculates CRC64.") + Add(new Option(new[] { - Argument = new Argument(() => true), - Required = false - }); + "--crc32", "-c" + }, () => true, "Calculates CRC32.")); - Add(new Option("--fletcher16", "Calculates Fletcher-16.") + Add(new Option("--crc64", () => true, "Calculates CRC64.")); + Add(new Option("--fletcher16", () => false, "Calculates Fletcher-16.")); + Add(new Option("--fletcher32", () => false, "Calculates Fletcher-32.")); + + Add(new Option(new[] { - Argument = new Argument(() => false), - Required = false - }); + "--md5", "-m" + }, () => true, "Calculates MD5.")); - Add(new Option("--fletcher32", "Calculates Fletcher-32.") + Add(new Option(new[] { - Argument = new Argument(() => false), - Required = false - }); + "--separated-tracks", "-t" + }, () => true, "Checksums each track separately.")); - Add(new Option(new[] - { - "--md5", "-m" - }, "Calculates MD5.") - { - Argument = new Argument(() => true), - Required = false - }); - - Add(new Option(new[] - { - "--separated-tracks", "-t" - }, "Checksums each track separately.") - { - Argument = new Argument(() => true), - Required = false - }); - - Add(new Option(new[] - { - "--sha1", "-s" - }, "Calculates SHA1.") - { - Argument = new Argument(() => true), - Required = false - }); - - Add(new Option("--sha256", "Calculates SHA256.") + Add(new Option(new[] { - Argument = new Argument(() => false), - Required = false - }); + "--sha1", "-s" + }, () => true, "Calculates SHA1.")); - Add(new Option("--sha384", "Calculates SHA384.") + Add(new Option("--sha256", () => false, "Calculates SHA256.")); + Add(new Option("--sha384", () => false, "Calculates SHA384.")); + Add(new Option("--sha512", () => true, "Calculates SHA512.")); + + Add(new Option(new[] { - Argument = new Argument(() => false), - Required = false - }); + "--spamsum", "-f" + }, () => true, "Calculates SpamSum fuzzy hash.")); - Add(new Option("--sha512", "Calculates SHA512.") + Add(new Option(new[] { - Argument = new Argument(() => true), - Required = false - }); - - Add(new Option(new[] - { - "--spamsum", "-f" - }, "Calculates SpamSum fuzzy hash.") - { - Argument = new Argument(() => true), - Required = false - }); - - Add(new Option(new[] - { - "--whole-disc", "-w" - }, "Checksums the whole disc.") - { - Argument = new Argument(() => true), - Required = false - }); + "--whole-disc", "-w" + }, () => true, "Checksums the whole disc.")); AddArgument(new Argument { diff --git a/Aaru/Commands/Image/Compare.cs b/Aaru/Commands/Image/Compare.cs index fa7f244e4..c8694398c 100644 --- a/Aaru/Commands/Image/Compare.cs +++ b/Aaru/Commands/Image/Compare.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands.Image; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.Linq; using System.Text; using Aaru.CommonTypes; diff --git a/Aaru/Commands/Image/Convert.cs b/Aaru/Commands/Image/Convert.cs index ea2ebd999..98ec8a9d3 100644 --- a/Aaru/Commands/Image/Convert.cs +++ b/Aaru/Commands/Image/Convert.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands.Image; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.IO; using System.Linq; using System.Text; @@ -59,192 +59,91 @@ sealed class ConvertImageCommand : Command { public ConvertImageCommand() : base("convert", "Converts one image to another format.") { - Add(new Option(new[] - { - "--cicm-xml", "-x" - }, "Take metadata from existing CICM XML sidecar.") - { - Argument = new Argument(() => null), - Required = false - }); - - Add(new Option("--comments", "Image comments.") + Add(new Option(new[] { - Argument = new Argument(() => null), - Required = false - }); + "--cicm-xml", "-x" + }, () => null, "Take metadata from existing CICM XML sidecar.")); - Add(new Option(new[] - { - "--count", "-c" - }, "How many sectors to convert at once.") - { - Argument = new Argument(() => 64), - Required = false - }); + Add(new Option("--comments", () => null, "Image comments.")); - Add(new Option("--creator", "Who (person) created the image?.") + Add(new Option(new[] { - Argument = new Argument(() => null), - Required = false - }); + "--count", "-c" + }, () => 64, "How many sectors to convert at once.")); - Add(new Option("--drive-manufacturer", - "Manufacturer of the drive used to read the media represented by the image.") + Add(new Option("--creator", () => null, "Who (person) created the image?.")); + + Add(new Option("--drive-manufacturer", () => null, + "Manufacturer of the drive used to read the media represented by the image.")); + + Add(new Option("--drive-model", () => null, + "Model of the drive used to read the media represented by the image.")); + + Add(new Option("--drive-revision", () => null, + "Firmware revision of the drive used to read the media represented by the image.")); + + Add(new Option("--drive-serial", () => null, + "Serial number of the drive used to read the media represented by the image.")); + + Add(new Option(new[] { - Argument = new Argument(() => null), - Required = false - }); + "--force", "-f" + }, "Continue conversion even if sector or media tags will be lost in the process.")); - Add(new Option("--drive-model", "Model of the drive used to read the media represented by the image.") + Add(new Option(new[] + { + "--format", "-p" + }, () => null, + "Format of the output image, as plugin name or plugin id. If not present, will try to detect it from output image extension.")); + + Add(new Option("--media-barcode", () => null, "Barcode of the media represented by the image.")); + + Add(new Option("--media-lastsequence", () => 0, + "Last media of the sequence the media represented by the image corresponds to.")); + + Add(new Option("--media-manufacturer", () => null, + "Manufacturer of the media represented by the image.")); + + Add(new Option("--media-model", () => null, "Model of the media represented by the image.")); + Add(new Option("--media-partnumber", () => null, "Part number of the media represented by the image.")); + Add(new Option("--media-sequence", () => 0, "Number in sequence for the media represented by the image.")); + Add(new Option("--media-serial", () => null, "Serial number of the media represented by the image.")); + Add(new Option("--media-title", () => null, "Title of the media represented by the image.")); + + Add(new Option(new[] { - Argument = new Argument(() => null), - Required = false - }); + "--options", "-O" + }, () => null, "Comma separated name=value pairs of options to pass to output image plugin.")); - Add(new Option("--drive-revision", - "Firmware revision of the drive used to read the media represented by the image.") + Add(new Option(new[] { - Argument = new Argument(() => null), - Required = false - }); + "--resume-file", "-r" + }, () => null, "Take list of dump hardware from existing resume file.")); - Add(new Option("--drive-serial", "Serial number of the drive used to read the media represented by the image.") + Add(new Option(new[] { - Argument = new Argument(() => null), - Required = false - }); + "--geometry", "-g" + }, () => null, "Force geometry, only supported in not tape block media. Specify as C/H/S.")); - Add(new Option(new[] - { - "--force", "-f" - }, "Continue conversion even if sector or media tags will be lost in the process.") - { - Argument = new Argument(() => false), - Required = false - }); - - Add(new Option(new[] - { - "--format", "-p" - }, - "Format of the output image, as plugin name or plugin id. If not present, will try to detect it from output image extension.") + Add(new Option(new[] { - Argument = new Argument(() => null), - Required = false - }); + "--fix-subchannel-position" + }, () => true, "Store subchannel according to the sector they describe.")); - Add(new Option("--media-barcode", "Barcode of the media represented by the image.") + Add(new Option(new[] { - Argument = new Argument(() => null), - Required = false - }); + "--fix-subchannel" + }, () => false, "Try to fix subchannel. Implies fixing subchannel position.")); - Add(new Option("--media-lastsequence", - "Last media of the sequence the media represented by the image corresponds to.") + Add(new Option(new[] { - Argument = new Argument(() => 0), - Required = false - }); + "--fix-subchannel-crc" + }, () => false, "If subchannel looks OK but CRC fails, rewrite it. Implies fixing subchannel.")); - Add(new Option("--media-manufacturer", "Manufacturer of the media represented by the image.") + Add(new Option(new[] { - Argument = new Argument(() => null), - Required = false - }); - - Add(new Option("--media-model", "Model of the media represented by the image.") - { - Argument = new Argument(() => null), - Required = false - }); - - Add(new Option("--media-partnumber", "Part number of the media represented by the image.") - { - Argument = new Argument(() => null), - Required = false - }); - - Add(new Option("--media-sequence", "Number in sequence for the media represented by the image.") - { - Argument = new Argument(() => 0), - Required = false - }); - - Add(new Option("--media-serial", "Serial number of the media represented by the image.") - { - Argument = new Argument(() => null), - Required = false - }); - - Add(new Option("--media-title", "Title of the media represented by the image.") - { - Argument = new Argument(() => null), - Required = false - }); - - Add(new Option(new[] - { - "--options", "-O" - }, "Comma separated name=value pairs of options to pass to output image plugin.") - { - Argument = new Argument(() => null), - Required = false - }); - - Add(new Option(new[] - { - "--resume-file", "-r" - }, "Take list of dump hardware from existing resume file.") - { - Argument = new Argument(() => null), - Required = false - }); - - Add(new Option(new[] - { - "--geometry", "-g" - }, "Force geometry, only supported in not tape block media. Specify as C/H/S.") - { - Argument = new Argument(() => null), - Required = false - }); - - Add(new Option(new[] - { - "--fix-subchannel-position" - }, "Store subchannel according to the sector they describe.") - { - Argument = new Argument(() => true), - Required = false - }); - - Add(new Option(new[] - { - "--fix-subchannel" - }, "Try to fix subchannel. Implies fixing subchannel position.") - { - Argument = new Argument(() => false), - Required = false - }); - - Add(new Option(new[] - { - "--fix-subchannel-crc" - }, "If subchannel looks OK but CRC fails, rewrite it. Implies fixing subchannel.") - { - Argument = new Argument(() => false), - Required = false - }); - - Add(new Option(new[] - { - "--generate-subchannels" - }, "Generates missing subchannels.") - { - Argument = new Argument(() => false), - Required = false - }); + "--generate-subchannels" + }, () => false, "Generates missing subchannels.")); AddArgument(new Argument { diff --git a/Aaru/Commands/Image/CreateSidecar.cs b/Aaru/Commands/Image/CreateSidecar.cs index 941b4fff7..17c88109b 100644 --- a/Aaru/Commands/Image/CreateSidecar.cs +++ b/Aaru/Commands/Image/CreateSidecar.cs @@ -34,7 +34,7 @@ namespace Aaru.Commands.Image; using System; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.IO; using System.Linq; using System.Text; @@ -55,34 +55,22 @@ sealed class CreateSidecarCommand : Command public CreateSidecarCommand() : base("create-sidecar", "Creates CICM Metadata XML sidecar.") { - Add(new Option(new[] - { - "--block-size", "-b" - }, - "Only used for tapes, indicates block size. Files in the folder whose size is not a multiple of this value will simply be ignored.") - { - Argument = new Argument(() => 512), - Required = false - }); + Add(new Option(new[] + { + "--block-size", "-b" + }, () => 512, + "Only used for tapes, indicates block size. Files in the folder whose size is not a multiple of this value will simply be ignored.")); - Add(new Option(new[] - { - "--encoding", "-e" - }, "Name of character encoding to use.") - { - Argument = new Argument(() => null), - Required = false - }); - - Add(new Option(new[] - { - "--tape", "-t" - }, - "When used indicates that input is a folder containing alphabetically sorted files extracted from a linear block-based tape with fixed block size (e.g. a SCSI tape device).") + Add(new Option(new[] { - Argument = new Argument(() => false), - Required = false - }); + "--encoding", "-e" + }, () => null, "Name of character encoding to use.")); + + Add(new Option(new[] + { + "--tape", "-t" + }, () => false, + "When used indicates that input is a folder containing alphabetically sorted files extracted from a linear block-based tape with fixed block size (e.g. a SCSI tape device).")); AddArgument(new Argument { diff --git a/Aaru/Commands/Image/Decode.cs b/Aaru/Commands/Image/Decode.cs index 6a7580a8c..932753512 100644 --- a/Aaru/Commands/Image/Decode.cs +++ b/Aaru/Commands/Image/Decode.cs @@ -34,7 +34,7 @@ namespace Aaru.Commands.Image; using System; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; @@ -49,41 +49,25 @@ sealed class DecodeCommand : Command { public DecodeCommand() : base("decode", "Decodes and pretty prints disk and/or sector tags.") { - Add(new Option(new[] - { - "--disk-tags", "-f" - }, "Decode disk tags.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--disk-tags", "-f" + }, () => true, "Decode disk tags.")); - Add(new Option(new[] - { - "--length", "-l" - }, "How many sectors to decode, or \"all\".") - { - Argument = new Argument(() => "all"), - Required = false - }); + Add(new Option(new[] + { + "--length", "-l" + }, () => "all", "How many sectors to decode, or \"all\".")); - Add(new Option(new[] - { - "--sector-tags", "-p" - }, "Decode sector tags.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--sector-tags", "-p" + }, () => true, "Decode sector tags.")); - Add(new Option(new[] - { - "--start", "-s" - }, "Sector to start decoding from.") - { - Argument = new Argument(() => 0), - Required = false - }); + Add(new Option(new[] + { + "--start", "-s" + }, () => 0, "Sector to start decoding from.")); AddArgument(new Argument { diff --git a/Aaru/Commands/Image/Entropy.cs b/Aaru/Commands/Image/Entropy.cs index 143405516..50989aead 100644 --- a/Aaru/Commands/Image/Entropy.cs +++ b/Aaru/Commands/Image/Entropy.cs @@ -34,7 +34,7 @@ namespace Aaru.Commands.Image; using System; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; @@ -49,32 +49,20 @@ sealed class EntropyCommand : Command public EntropyCommand() : base("entropy", "Calculates entropy and/or duplicated sectors of an image.") { - Add(new Option(new[] - { - "--duplicated-sectors", "-p" - }, "Calculates how many sectors are duplicated (have same exact data in user area).") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--duplicated-sectors", "-p" + }, () => true, "Calculates how many sectors are duplicated (have same exact data in user area).")); - Add(new Option(new[] - { - "--separated-tracks", "-t" - }, "Calculates entropy for each track separately.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--separated-tracks", "-t" + }, () => true, "Calculates entropy for each track separately.")); - Add(new Option(new[] - { - "--whole-disc", "-w" - }, "Calculates entropy for the whole disc.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--whole-disc", "-w" + }, () => true, "Calculates entropy for the whole disc.")); AddArgument(new Argument { diff --git a/Aaru/Commands/Image/Info.cs b/Aaru/Commands/Image/Info.cs index 6c582c955..9ca921bd8 100644 --- a/Aaru/Commands/Image/Info.cs +++ b/Aaru/Commands/Image/Info.cs @@ -34,7 +34,7 @@ namespace Aaru.Commands.Image; using System; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; diff --git a/Aaru/Commands/Image/Options.cs b/Aaru/Commands/Image/Options.cs index 94437ab4b..0ab0e925c 100644 --- a/Aaru/Commands/Image/Options.cs +++ b/Aaru/Commands/Image/Options.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands.Image; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.Linq; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; diff --git a/Aaru/Commands/Image/Print.cs b/Aaru/Commands/Image/Print.cs index 893fc846a..f9a0a1de7 100644 --- a/Aaru/Commands/Image/Print.cs +++ b/Aaru/Commands/Image/Print.cs @@ -34,7 +34,7 @@ namespace Aaru.Commands.Image; using System; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; @@ -47,41 +47,25 @@ sealed class PrintHexCommand : Command { public PrintHexCommand() : base("print", "Prints a sector, in hexadecimal values, to the console.") { - Add(new Option(new[] - { - "--length", "-l" - }, "How many sectors to print.") - { - Argument = new Argument(() => 1), - Required = false - }); + Add(new Option(new[] + { + "--length", "-l" + }, () => 1, "How many sectors to print.")); - Add(new Option(new[] - { - "--long-sectors", "-r" - }, "Print sectors with tags included.") - { - Argument = new Argument(() => false), - Required = false - }); + Add(new Option(new[] + { + "--long-sectors", "-r" + }, () => false, "Print sectors with tags included.")); - Add(new Option(new[] - { - "--start", "-s" - }, "Starting sector.") - { - Argument = new Argument(), - Required = true - }); + Add(new Option(new[] + { + "--start", "-s" + }, "Starting sector.")); - Add(new Option(new[] - { - "--width", "-w" - }, "How many bytes to print per line.") - { - Argument = new Argument(() => 32), - Required = false - }); + Add(new Option(new[] + { + "--width", "-w" + }, () => 32, "How many bytes to print per line.")); AddArgument(new Argument { diff --git a/Aaru/Commands/Image/Verify.cs b/Aaru/Commands/Image/Verify.cs index c06e65837..e0087bf87 100644 --- a/Aaru/Commands/Image/Verify.cs +++ b/Aaru/Commands/Image/Verify.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands.Image; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; @@ -48,23 +48,15 @@ sealed class VerifyCommand : Command { public VerifyCommand() : base("verify", "Verifies a disc image integrity, and if supported, sector integrity.") { - Add(new Option(new[] - { - "--verify-disc", "-w" - }, "Verify disc image if supported.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--verify-disc", "-w" + }, () => true, "Verify disc image if supported.")); - Add(new Option(new[] - { - "--verify-sectors", "-s" - }, "Verify all sectors if supported.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--verify-sectors", "-s" + }, () => true, "Verify all sectors if supported.")); AddArgument(new Argument { diff --git a/Aaru/Commands/ListEncodings.cs b/Aaru/Commands/ListEncodings.cs index f42dd4a32..ce95d5231 100644 --- a/Aaru/Commands/ListEncodings.cs +++ b/Aaru/Commands/ListEncodings.cs @@ -34,7 +34,7 @@ namespace Aaru.Commands; using System; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.Linq; using System.Text; using Aaru.CommonTypes.Enums; diff --git a/Aaru/Commands/ListNamespaces.cs b/Aaru/Commands/ListNamespaces.cs index 466d72780..5632df247 100644 --- a/Aaru/Commands/ListNamespaces.cs +++ b/Aaru/Commands/ListNamespaces.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.Linq; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; diff --git a/Aaru/Commands/Media/Dump.cs b/Aaru/Commands/Media/Dump.cs index 304b04ffc..11e70f395 100644 --- a/Aaru/Commands/Media/Dump.cs +++ b/Aaru/Commands/Media/Dump.cs @@ -36,7 +36,7 @@ namespace Aaru.Commands.Media; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.IO; using System.Linq; using System.Text; @@ -64,130 +64,67 @@ sealed class DumpMediaCommand : Command public DumpMediaCommand() : base("dump", "Dumps the media inserted on a device to a media image.") { - Add(new Option(new[] - { - "--cicm-xml", "-x" - }, "Take metadata from existing CICM XML sidecar.") - { - Argument = new Argument(() => null), - Required = false - }); - - Add(new Option(new[] - { - "--encoding", "-e" - }, "Name of character encoding to use.") - { - Argument = new Argument(() => null), - Required = false - }); - - Add(new Option("--first-pregap", "Try to read first track pregap. Only applicable to CD/DDCD/GD.") + Add(new Option(new[] { - Argument = new Argument(() => false), - Required = false - }); + "--cicm-xml", "-x" + }, () => null, "Take metadata from existing CICM XML sidecar.")); - Add(new Option("--fix-offset", "Fix audio tracks offset. Only applicable to CD/GD.") + Add(new Option(new[] { - Argument = new Argument(() => true), - Required = false - }); + "--encoding", "-e" + }, () => null, "Name of character encoding to use.")); - Add(new Option(new[] - { - "--force", "-f" - }, "Continue dump whatever happens.") - { - Argument = new Argument(() => false), - Required = false - }); + Add(new Option("--first-pregap", () => false, + "Try to read first track pregap. Only applicable to CD/DDCD/GD.")); - Add(new Option(new[] - { - "--format", "-t" - }, - "Format of the output image, as plugin name or plugin id. If not present, will try to detect it from output image extension.") + Add(new Option("--fix-offset", () => true, "Fix audio tracks offset. Only applicable to CD/GD.")); + + Add(new Option(new[] { - Argument = new Argument(() => null), - Required = false - }); + "--force", "-f" + }, () => false, "Continue dump whatever happens.")); - Add(new Option("--metadata", "Enables creating CICM XML sidecar.") + Add(new Option(new[] + { + "--format", "-t" + }, () => null, + "Format of the output image, as plugin name or plugin id. If not present, will try to detect it from output image extension.")); + + Add(new Option("--metadata", () => true, "Enables creating CICM XML sidecar.")); + + Add(new Option("--trim", () => true, "Enables trimming errored from skipped sectors.")); + + Add(new Option(new[] { - Argument = new Argument(() => true), - Required = false - }); + "--options", "-O" + }, () => null, "Comma separated name=value pairs of options to pass to output image plugin.")); - Add(new Option("--trim", "Enables trimming errored from skipped sectors.") + Add(new Option("--persistent", () => false, "Try to recover partial or incorrect data.")); + + Add(new Option(new[] { - Argument = new Argument(() => true), - Required = false - }); + "--resume", "-r" + }, () => true, "Create/use resume mapfile.")); - Add(new Option(new[] - { - "--options", "-O" - }, "Comma separated name=value pairs of options to pass to output image plugin.") - { - Argument = new Argument(() => null), - Required = false - }); - - Add(new Option("--persistent", "Try to recover partial or incorrect data.") + Add(new Option(new[] { - Argument = new Argument(() => false), - Required = false - }); + "--retry-passes", "-p" + }, () => 5, "How many retry passes to do.")); - Add(new Option(new[] - { - "--resume", "-r" - }, "Create/use resume mapfile.") - { - Argument = new Argument(() => true), - Required = false - }); - - Add(new Option(new[] - { - "--retry-passes", "-p" - }, "How many retry passes to do.") - { - Argument = new Argument(() => 5), - Required = false - }); - - Add(new Option(new[] - { - "--skip", "-k" - }, "When an unreadable sector is found skip this many sectors.") - { - Argument = new Argument(() => 512), - Required = false - }); - - Add(new Option(new[] - { - "--stop-on-error", "-s" - }, "Stop media dump on first error.") - { - Argument = new Argument(() => false), - Required = false - }); - - Add(new Option("--subchannel", - "Subchannel to dump. Only applicable to CD/GD. Values: any, rw, rw-or-pq, pq, none.") + Add(new Option(new[] { - Argument = new Argument(() => "any"), - Required = false - }); + "--skip", "-k" + }, () => 512, "When an unreadable sector is found skip this many sectors.")); - Add(new Option("--speed", "Speed to dump. Only applicable to optical drives, 0 for maximum.") + Add(new Option(new[] { - Argument = new Argument(() => 0), - Required = false - }); + "--stop-on-error", "-s" + }, () => false, "Stop media dump on first error.")); + + Add(new Option("--subchannel", () => "any", + "Subchannel to dump. Only applicable to CD/GD. Values: any, rw, rw-or-pq, pq, none.")); + + Add(new Option("--speed", () => 0, "Speed to dump. Only applicable to optical drives, 0 for maximum.")); AddArgument(new Argument { @@ -204,113 +141,65 @@ sealed class DumpMediaCommand : Command Name = "output-path" }); - Add(new Option(new[] - { - "--private" - }, "Do not store paths and serial numbers in log or metadata.") - { - Argument = new Argument(() => false), - Required = false - }); + Add(new Option(new[] + { + "--private" + }, () => false, "Do not store paths and serial numbers in log or metadata.")); - Add(new Option(new[] - { - "--fix-subchannel-position" - }, "Store subchannel according to the sector they describe.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--fix-subchannel-position" + }, () => true, "Store subchannel according to the sector they describe.")); - Add(new Option(new[] - { - "--retry-subchannel" - }, "Retry subchannel. Implies fixing subchannel position.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--retry-subchannel" + }, () => true, "Retry subchannel. Implies fixing subchannel position.")); - Add(new Option(new[] - { - "--fix-subchannel" - }, "Try to fix subchannel. Implies fixing subchannel position.") - { - Argument = new Argument(() => false), - Required = false - }); + Add(new Option(new[] + { + "--fix-subchannel" + }, () => false, "Try to fix subchannel. Implies fixing subchannel position.")); - Add(new Option(new[] - { - "--fix-subchannel-crc" - }, "If subchannel looks OK but CRC fails, rewrite it. Implies fixing subchannel.") - { - Argument = new Argument(() => false), - Required = false - }); + Add(new Option(new[] + { + "--fix-subchannel-crc" + }, () => false, "If subchannel looks OK but CRC fails, rewrite it. Implies fixing subchannel.")); - Add(new Option(new[] - { - "--generate-subchannels" - }, "Generates missing subchannels (they don't count as dumped in resume file).") - { - Argument = new Argument(() => false), - Required = false - }); + Add(new Option(new[] + { + "--generate-subchannels" + }, () => false, "Generates missing subchannels (they don't count as dumped in resume file).")); - Add(new Option(new[] - { - "--skip-cdiready-hole" - }, "Skip the hole between data and audio in a CD-i Ready disc.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--skip-cdiready-hole" + }, () => true, "Skip the hole between data and audio in a CD-i Ready disc.")); - Add(new Option(new[] - { - "--eject" - }, "Eject media after dump finishes.") - { - Argument = new Argument(() => false), - Required = false - }); + Add(new Option(new[] + { + "--eject" + }, () => false, "Eject media after dump finishes.")); - Add(new Option(new[] - { - "--max-blocks" - }, "Maximum number of blocks to read at once.") - { - Argument = new Argument(() => 64), - Required = false - }); + Add(new Option(new[] + { + "--max-blocks" + }, () => 64, "Maximum number of blocks to read at once.")); - Add(new Option(new[] - { - "--use-buffered-reads" - }, "For MMC/SD, use OS buffered reads if CMD23 is not supported.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--use-buffered-reads" + }, () => true, "For MMC/SD, use OS buffered reads if CMD23 is not supported.")); - Add(new Option(new[] - { - "--store-encrypted" - }, "Store encrypted data as is.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--store-encrypted" + }, () => true, "Store encrypted data as is.")); - Add(new Option(new[] - { - "--title-keys" - }, "Try to read the title keys from CSS encrypted DVDs (very slow).") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--title-keys" + }, () => true, "Try to read the title keys from CSS encrypted DVDs (very slow).")); Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); } diff --git a/Aaru/Commands/Media/Info.cs b/Aaru/Commands/Media/Info.cs index 664b17ebd..01aa7ab43 100644 --- a/Aaru/Commands/Media/Info.cs +++ b/Aaru/Commands/Media/Info.cs @@ -35,7 +35,7 @@ namespace Aaru.Commands.Media; using System; using System.Collections.Generic; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using System.Linq; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; @@ -67,14 +67,10 @@ sealed class MediaInfoCommand : Command { public MediaInfoCommand() : base("info", "Gets information about the media inserted on a device.") { - Add(new Option(new[] - { - "--output-prefix", "-w" - }, "Write binary responses from device with that prefix.") - { - Argument = new Argument(() => null), - Required = false - }); + Add(new Option(new[] + { + "--output-prefix", "-w" + }, () => null, "Write binary responses from device with that prefix.")); AddArgument(new Argument { diff --git a/Aaru/Commands/Media/Scan.cs b/Aaru/Commands/Media/Scan.cs index ccfd5111f..c93cd1e73 100644 --- a/Aaru/Commands/Media/Scan.cs +++ b/Aaru/Commands/Media/Scan.cs @@ -34,7 +34,7 @@ namespace Aaru.Commands.Media; using System; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using Aaru.CommonTypes.Enums; using Aaru.Console; using Aaru.Core; @@ -48,32 +48,20 @@ sealed class MediaScanCommand : Command public MediaScanCommand() : base("scan", "Scans the media inserted on a device.") { - Add(new Option(new[] - { - "--mhdd-log", "-m" - }, "Write a log of the scan in the format used by MHDD.") - { - Argument = new Argument(() => null), - Required = false - }); + Add(new Option(new[] + { + "--mhdd-log", "-m" + }, () => null, "Write a log of the scan in the format used by MHDD.")); - Add(new Option(new[] - { - "--ibg-log", "-b" - }, "Write a log of the scan in the format used by ImgBurn.") - { - Argument = new Argument(() => null), - Required = false - }); + Add(new Option(new[] + { + "--ibg-log", "-b" + }, () => null, "Write a log of the scan in the format used by ImgBurn.")); - Add(new Option(new[] - { - "--use-buffered-reads" - }, "For MMC/SD, use OS buffered reads if CMD23 is not supported.") - { - Argument = new Argument(() => true), - Required = false - }); + Add(new Option(new[] + { + "--use-buffered-reads" + }, () => true, "For MMC/SD, use OS buffered reads if CMD23 is not supported.")); AddArgument(new Argument { diff --git a/Aaru/Commands/Remote.cs b/Aaru/Commands/Remote.cs index efaac39c0..20e079a11 100644 --- a/Aaru/Commands/Remote.cs +++ b/Aaru/Commands/Remote.cs @@ -36,7 +36,7 @@ namespace Aaru.Commands; using System; using System.CommandLine; -using System.CommandLine.Invocation; +using System.CommandLine.NamingConventionBinder; using Aaru.CommonTypes.Enums; using Aaru.Console; using Aaru.Core; diff --git a/Aaru/Main.cs b/Aaru/Main.cs index 85a39af6d..bf93092e7 100644 --- a/Aaru/Main.cs +++ b/Aaru/Main.cs @@ -201,29 +201,22 @@ class MainClass var rootCommand = new RootCommand(); - rootCommand.AddGlobalOption(new Option(new[] - { - "--verbose", "-v" - }, "Shows verbose output.") - { - Argument = new Argument(() => false) - }); + rootCommand.AddGlobalOption(new Option(new[] + { + "--verbose", "-v" + }, () => false, "Shows verbose output.")); - rootCommand.AddGlobalOption(new Option(new[] - { - "--debug", "-d" - }, "Shows debug output from plugins.") - { - Argument = new Argument(() => false) - }); + rootCommand.AddGlobalOption(new Option(new[] + { + "--debug", "-d" + }, () => false, "Shows debug output from plugins.")); - rootCommand.AddGlobalOption(new Option(new[] - { - "--pause" - }, "Pauses before exiting.") - { - Argument = new Argument(() => false) - }); + var pauseOption = new Option(new[] + { + "--pause" + }, () => false, "Pauses before exiting."); + + rootCommand.AddGlobalOption(pauseOption); rootCommand.Description = $"{_assemblyTitle} {_assemblyVersion?.InformationalVersion}\n{_assemblyCopyright}"; @@ -244,7 +237,7 @@ class MainClass Statistics.SaveStats(); - if(rootCommand.Parse(args).RootCommandResult.ValueForOption("--pause")?.Equals(true) != true) + if(!rootCommand.Parse(args).RootCommandResult.GetValueForOption(pauseOption)) return ret; AaruConsole.WriteLine("Press any key to exit.");