From d6dbbbe92887beb7ded4eddd20c334543eafa076 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 18 Oct 2025 18:47:27 -0400 Subject: [PATCH] Add list configuration commandline feature (fixes #906) --- CHANGELIST.md | 1 + MPF.CLI/Features/BaseFeature.cs | 1 + MPF.CLI/Program.cs | 2 + MPF.Check/Features/BaseFeature.cs | 1 + MPF.Check/Program.cs | 2 + MPF.Frontend/EnumExtensions.cs | 24 ++++ MPF.Frontend/Features/ListConfigFeature.cs | 150 +++++++++++++++++++++ 7 files changed, 181 insertions(+) create mode 100644 MPF.Frontend/Features/ListConfigFeature.cs diff --git a/CHANGELIST.md b/CHANGELIST.md index f8af420b..ce2aab65 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -28,6 +28,7 @@ - Make Check flags toggle if config used - Add console print when Check loads from config - Add Ukrainian translation (superg) +- Add list configuration commandline feature ### 3.5.0 (2025-10-10) diff --git a/MPF.CLI/Features/BaseFeature.cs b/MPF.CLI/Features/BaseFeature.cs index d89070f7..40c1fad2 100644 --- a/MPF.CLI/Features/BaseFeature.cs +++ b/MPF.CLI/Features/BaseFeature.cs @@ -235,6 +235,7 @@ namespace MPF.CLI.Features Console.WriteLine("?, h, help Show this help text"); Console.WriteLine("version Print the program version"); Console.WriteLine("lc, listcodes List supported comment/content site codes"); + Console.WriteLine("lo, listconfig List current configuration values"); Console.WriteLine("lm, listmedia List supported media types"); Console.WriteLine("ls, listsystems List supported system types"); Console.WriteLine("lp, listprograms List supported dumping program outputs"); diff --git a/MPF.CLI/Program.cs b/MPF.CLI/Program.cs index fc57ab78..ba57ae27 100644 --- a/MPF.CLI/Program.cs +++ b/MPF.CLI/Program.cs @@ -58,6 +58,7 @@ namespace MPF.CLI case Help: BaseFeature.DisplayHelp(); return; case VersionFeature version: version.Execute(); return; case ListCodesFeature lc: lc.Execute(); return; + case ListConfigFeature lc: lc.Execute(); return; case ListMediaTypesFeature lm: lm.Execute(); return; case ListProgramsFeature lp: lp.Execute(); return; case ListSystemsFeature ls: ls.Execute(); return; @@ -127,6 +128,7 @@ namespace MPF.CLI commandSet.Add(new Help()); commandSet.Add(new VersionFeature()); commandSet.Add(new ListCodesFeature()); + commandSet.Add(new ListConfigFeature()); commandSet.Add(new ListMediaTypesFeature()); commandSet.Add(new ListSystemsFeature()); commandSet.Add(new ListProgramsFeature()); diff --git a/MPF.Check/Features/BaseFeature.cs b/MPF.Check/Features/BaseFeature.cs index 2b355ae0..d3319108 100644 --- a/MPF.Check/Features/BaseFeature.cs +++ b/MPF.Check/Features/BaseFeature.cs @@ -141,6 +141,7 @@ namespace MPF.Check.Features Console.WriteLine("?, h, help Show this help text"); Console.WriteLine("version Print the program version"); Console.WriteLine("lc, listcodes List supported comment/content site codes"); + Console.WriteLine("lo, listconfig List current configuration values"); Console.WriteLine("lm, listmedia List supported media types"); Console.WriteLine("ls, listsystems List supported system types"); Console.WriteLine("lp, listprograms List supported dumping program outputs"); diff --git a/MPF.Check/Program.cs b/MPF.Check/Program.cs index 37993fd6..38a6e5fd 100644 --- a/MPF.Check/Program.cs +++ b/MPF.Check/Program.cs @@ -36,6 +36,7 @@ namespace MPF.Check case Help: BaseFeature.DisplayHelp(); return; case VersionFeature version: version.Execute(); return; case ListCodesFeature lc: lc.Execute(); return; + case ListConfigFeature lc: lc.Execute(); return; case ListMediaTypesFeature lm: lm.Execute(); return; case ListProgramsFeature lp: lp.Execute(); return; case ListSystemsFeature ls: ls.Execute(); return; @@ -107,6 +108,7 @@ namespace MPF.Check commandSet.Add(new Help()); commandSet.Add(new VersionFeature()); commandSet.Add(new ListCodesFeature()); + commandSet.Add(new ListConfigFeature()); commandSet.Add(new ListMediaTypesFeature()); commandSet.Add(new ListSystemsFeature()); commandSet.Add(new ListProgramsFeature()); diff --git a/MPF.Frontend/EnumExtensions.cs b/MPF.Frontend/EnumExtensions.cs index 9790c542..fb6aa580 100644 --- a/MPF.Frontend/EnumExtensions.cs +++ b/MPF.Frontend/EnumExtensions.cs @@ -160,6 +160,14 @@ namespace MPF.Frontend }; } + /// + /// Get the string representation of the RedumperReadMethod enum values + /// + /// RedumperReadMethod value to convert + /// String representing the value, if possible + public static string LongName(this RedumperReadMethod method) + => ((RedumperReadMethod?)method).LongName(); + /// /// Get the string representation of the RedumperReadMethod enum values /// @@ -177,6 +185,14 @@ namespace MPF.Frontend }; } + /// + /// Get the string representation of the RedumperSectorOrder enum values + /// + /// RedumperSectorOrder value to convert + /// String representing the value, if possible + public static string LongName(this RedumperSectorOrder order) + => ((RedumperSectorOrder?)order).LongName(); + /// /// Get the string representation of the RedumperSectorOrder enum values /// @@ -196,6 +212,14 @@ namespace MPF.Frontend }; } + /// + /// Get the string representation of the RedumperDriveType enum values + /// + /// RedumperDriveType value to convert + /// String representing the value, if possible + public static string LongName(this RedumperDriveType type) + => ((RedumperDriveType?)type).LongName(); + /// /// Get the string representation of the RedumperDriveType enum values /// diff --git a/MPF.Frontend/Features/ListConfigFeature.cs b/MPF.Frontend/Features/ListConfigFeature.cs new file mode 100644 index 00000000..a9821e30 --- /dev/null +++ b/MPF.Frontend/Features/ListConfigFeature.cs @@ -0,0 +1,150 @@ +using System; +using MPF.Frontend; +using MPF.Frontend.Tools; +using SabreTools.RedumpLib.Data; + +namespace MPF.Frontend.Features +{ + public class ListConfigFeature : SabreTools.CommandLine.Feature + { + #region Feature Definition + + public const string DisplayName = "listconfig"; + + private static readonly string[] _flags = ["lo", "listconfig"]; + + private const string _description = "List current configuration values"; + + #endregion + + public ListConfigFeature() + : base(DisplayName, _flags, _description) + { + } + + /// + public override bool Execute() + { + // Try to load the current config + var options = OptionsLoader.LoadFromConfig(); + if (options.FirstRun) + { + Console.WriteLine("No valid configuration found!"); + return true; + } + + // Paths + Console.WriteLine("Paths:"); + Console.WriteLine($" Aaru Path = {options.AaruPath}"); + Console.WriteLine($" DiscImageCreator Path = {options.DiscImageCreatorPath}"); + Console.WriteLine($" Redumper Path = {options.RedumperPath}"); + Console.WriteLine($" Default Program = {options.InternalProgram.LongName()}"); + Console.WriteLine(); + + // UI Defaults + Console.WriteLine("UI Defaults:"); + Console.WriteLine($" Dark Mode = {options.EnableDarkMode}"); + Console.WriteLine($" Purp Mode = {options.EnablePurpMode}"); + Console.WriteLine($" Custom Background Color = {options.CustomBackgroundColor}"); + Console.WriteLine($" Custom Text Color = {options.CustomTextColor}"); + Console.WriteLine($" Check for Updates on Startup = {options.CheckForUpdatesOnStartup}"); + Console.WriteLine($" Copy Update URL to Clipboard = {options.CopyUpdateUrlToClipboard}"); + Console.WriteLine($" Fast Label Update = {options.FastUpdateLabel}"); + Console.WriteLine($" Default Interface Language = {options.DefaultInterfaceLanguage.LongName()}"); + Console.WriteLine($" Default Output Path = {options.DefaultOutputPath}"); + Console.WriteLine($" Default System = {options.DefaultSystem.LongName()}"); + Console.WriteLine($" Show Debug Menu Item = {options.ShowDebugViewMenuItem}"); + Console.WriteLine(); + + // Dumping Speeds + Console.WriteLine("Dumping Speeds:"); + Console.WriteLine($" Default CD Speed = {options.PreferredDumpSpeedCD}"); + Console.WriteLine($" Default DVD Speed = {options.PreferredDumpSpeedDVD}"); + Console.WriteLine($" Default HD-DVD Speed = {options.PreferredDumpSpeedHDDVD}"); + Console.WriteLine($" Default Blu-ray Speed = {options.PreferredDumpSpeedBD}"); + Console.WriteLine(); + + // Aaru + Console.WriteLine("Aaru-Specific Options:"); + Console.WriteLine($" Enable Debug = {options.AaruEnableDebug}"); + Console.WriteLine($" Enable Verbose = {options.AaruEnableVerbose}"); + Console.WriteLine($" Force Dumping = {options.AaruForceDumping}"); + Console.WriteLine($" Reread Count = {options.AaruRereadCount}"); + Console.WriteLine($" Strip Personal Data = {options.AaruStripPersonalData}"); + Console.WriteLine(); + + // DiscImageCreator + Console.WriteLine("DiscImageCreator-Specific Options:"); + Console.WriteLine($" Multi-Sector Read Flag = {options.DICMultiSectorRead}"); + Console.WriteLine($" Multi-Sector Read Value = {options.DICMultiSectorReadValue}"); + Console.WriteLine($" Overly-Secure Flags = {options.DICParanoidMode}"); + Console.WriteLine($" Quiet Flag = {options.DICQuietMode}"); + Console.WriteLine($" CD Reread Count = {options.DICRereadCount}"); + Console.WriteLine($" DVD Reread Count = {options.DICDVDRereadCount}"); + Console.WriteLine($" Use CMI Flag = {options.DICUseCMIFlag}"); + Console.WriteLine(); + + // Redumper + Console.WriteLine("Redumper-Specific Options:"); + Console.WriteLine($" Enable Skeleton = {options.RedumperEnableSkeleton}"); + Console.WriteLine($" Enable Verbose = {options.RedumperEnableVerbose}"); + Console.WriteLine($" Lead-in Retry Count = {options.RedumperLeadinRetryCount}"); + Console.WriteLine($" Non-Redump Mode = {options.RedumperNonRedumpMode}"); + Console.WriteLine($" Drive Type = {options.RedumperDriveType.LongName()}"); + Console.WriteLine($" Read Method = {options.RedumperReadMethod.LongName()}"); + Console.WriteLine($" Sector Order = {options.RedumperSectorOrder.LongName()}"); + Console.WriteLine($" Reread Count = {options.RedumperRereadCount}"); + Console.WriteLine($" Refine Sector Mode = {options.RedumperRefineSectorMode}"); + Console.WriteLine(); + + // Extra Dumping Options + Console.WriteLine("Extra Dumping Options:"); + Console.WriteLine($" Scan for Protection = {options.ScanForProtection}"); + Console.WriteLine($" Add Placeholders = {options.AddPlaceholders}"); + Console.WriteLine($" Prompt for Media Information = {options.PromptForDiscInformation}"); + Console.WriteLine($" Pull All Information = {options.PullAllInformation}"); + Console.WriteLine($" Enable Tabs in Input Fields = {options.EnableTabsInInputFields}"); + Console.WriteLine($" Enable Redump Compatibility = {options.EnableRedumpCompatibility}"); + Console.WriteLine($" Show Disc Eject Reminder = {options.ShowDiscEjectReminder}"); + Console.WriteLine($" Ignore Fixed Drives = {options.IgnoreFixedDrives}"); + Console.WriteLine($" Add Filename Suffix = {options.AddFilenameSuffix}"); + Console.WriteLine($" Output Submission JSON = {options.OutputSubmissionJSON}"); + Console.WriteLine($" Include Artifacts = {options.IncludeArtifacts}"); + Console.WriteLine($" Compress Log Files = {options.CompressLogFiles}"); + Console.WriteLine($" Log Compression = {options.LogCompression.LongName()}"); + Console.WriteLine($" Delete Unnecessary Files = {options.DeleteUnnecessaryFiles}"); + Console.WriteLine($" Create IRD After Dumping = {options.CreateIRDAfterDumping}"); + Console.WriteLine(); + + // Skip Options + Console.WriteLine("Skip Options:"); + Console.WriteLine($" Skip System Detection = {options.SkipSystemDetection}"); + Console.WriteLine(); + + // Protection Scanning Options + Console.WriteLine("Protection Scanning Options:"); + Console.WriteLine($" Scan Archives for Protection = {options.ScanArchivesForProtection}"); + Console.WriteLine($" Include Debug Protection Information = {options.IncludeDebugProtectionInformation}"); + Console.WriteLine($" Hide Drive Letters = {options.HideDriveLetters}"); + Console.WriteLine(); + + // Logging Options + Console.WriteLine("Logging Options:"); + Console.WriteLine($" Verbose Logging = {options.VerboseLogging}"); + Console.WriteLine($" Open Log Window at Startup = {options.OpenLogWindowAtStartup}"); + Console.WriteLine(); + + // Redump Login Information + Console.WriteLine("Redump Login Information:"); + Console.WriteLine($" Retrieve Match Information = {options.RetrieveMatchInformation}"); + Console.WriteLine($" Redump Username = {options.RedumpUsername}"); + Console.WriteLine($" Redump Password = {(string.IsNullOrEmpty(options.RedumpPassword) ? "[UNSET]" : "[SET]")}"); + Console.WriteLine(); + + return true; + } + + /// + public override bool VerifyInputs() => true; + } +}