diff --git a/CHANGELIST.md b/CHANGELIST.md
index 2f4104a5..0349d555 100644
--- a/CHANGELIST.md
+++ b/CHANGELIST.md
@@ -55,6 +55,7 @@
- Move and update options loader; clean up Check
- Move helper methods around
- Consolidate Redump login testing
+- Separate common arguments to new helper
### 2.3 (2022-02-05)
- Start overhauling Redump information pulling, again
diff --git a/MPF.Check/Program.cs b/MPF.Check/Program.cs
index b1649413..d1090198 100644
--- a/MPF.Check/Program.cs
+++ b/MPF.Check/Program.cs
@@ -14,32 +14,14 @@ namespace MPF.Check
{
public static void Main(string[] args)
{
- // Try processing the standalone arguments first
+ // Try processing the standalone arguments
if (ProcessStandaloneArguments(args))
return;
- // All other use requires at least 3 arguments
- if (args.Length < 3)
- {
- DisplayHelp("Invalid number of arguments");
+ // Try processing the common arguments
+ (bool success, MediaType mediaType, RedumpSystem? knownSystem) = ProcessCommonArguments(args);
+ if (!success)
return;
- }
-
- // Check the MediaType
- var mediaType = EnumConverter.ToMediaType(args[0].Trim('"'));
- if (mediaType == MediaType.NONE)
- {
- DisplayHelp($"{args[0]} is not a recognized media type");
- return;
- }
-
- // Check the RedumpSystem
- var knownSystem = Extensions.ToRedumpSystem(args[1].Trim('"'));
- if (knownSystem == null)
- {
- DisplayHelp($"{args[1]} is not a recognized system");
- return;
- }
// Loop through and process options
(Options options, string path, int startIndex) = OptionsLoader.LoadFromArguments(args, startIndex: 2);
@@ -109,6 +91,38 @@ namespace MPF.Check
Console.WriteLine();
}
+ ///
+ /// Process common arguments for all functionality
+ ///
+ /// True if all arguments pass, false otherwise
+ private static (bool, MediaType, RedumpSystem?) ProcessCommonArguments(string[] args)
+ {
+ // All other use requires at least 3 arguments
+ if (args.Length < 3)
+ {
+ DisplayHelp("Invalid number of arguments");
+ return (false, MediaType.NONE, null);
+ }
+
+ // Check the MediaType
+ var mediaType = EnumConverter.ToMediaType(args[0].Trim('"'));
+ if (mediaType == MediaType.NONE)
+ {
+ DisplayHelp($"{args[0]} is not a recognized media type");
+ return (false, MediaType.NONE, null);
+ }
+
+ // Check the RedumpSystem
+ var knownSystem = Extensions.ToRedumpSystem(args[1].Trim('"'));
+ if (knownSystem == null)
+ {
+ DisplayHelp($"{args[1]} is not a recognized system");
+ return (false, MediaType.NONE, null);
+ }
+
+ return (true, mediaType, knownSystem);
+ }
+
///
/// Process any standalone arguments for the program
///