Files
MPF/MPF.Check/Program.cs

154 lines
7.2 KiB
C#
Raw Normal View History

using System;
2025-10-06 11:00:59 -04:00
using System.Collections.Generic;
2024-07-24 11:45:12 -04:00
#if NET40
using System.Threading.Tasks;
#endif
2025-10-06 10:34:11 -04:00
using MPF.Check.Features;
2025-10-06 11:00:59 -04:00
using MPF.Frontend.Features;
using SabreTools.CommandLine;
using SabreTools.CommandLine.Features;
2020-11-10 17:43:21 -08:00
namespace MPF.Check
{
public class Program
{
public static void Main(string[] args)
{
2025-10-06 15:25:11 -04:00
// Create the command set
2025-10-06 16:34:19 -04:00
var mainFeature = new MainFeature();
var commandSet = CreateCommands(mainFeature);
2025-10-06 15:25:11 -04:00
// If we have no args, show the help and quit
if (args == null || args.Length == 0)
2023-10-10 15:15:42 -04:00
{
2025-10-06 15:25:11 -04:00
DisplayHelp();
2019-04-04 00:37:17 -07:00
return;
2023-10-10 15:15:42 -04:00
}
2019-04-04 00:37:17 -07:00
2025-10-06 15:25:11 -04:00
// Get the first argument as a feature flag
string featureName = args[0];
2025-04-30 16:49:28 -04:00
2025-10-06 15:25:11 -04:00
// Try processing the standalone arguments
var topLevel = commandSet.GetTopLevel(featureName);
switch (topLevel)
2025-04-30 16:49:28 -04:00
{
2025-10-06 15:25:11 -04:00
// Standalone Options
case Help: DisplayHelp(); return;
case VersionFeature version: version.Execute(); return;
case ListCodesFeature lc: lc.Execute(); return;
case ListMediaTypesFeature lm: lm.Execute(); return;
case ListProgramsFeature lp: lp.Execute(); return;
case ListSystemsFeature ls: ls.Execute(); return;
// Interactive Mode
case InteractiveFeature interactive:
2025-10-06 16:06:23 -04:00
interactive.ProcessArgs(args, 0);
2025-10-06 15:25:11 -04:00
interactive.Execute();
break;
2025-04-30 16:49:28 -04:00
2025-10-06 15:25:11 -04:00
// Default Behavior
default:
mainFeature.ProcessArgs(args, 0);
2025-10-06 16:06:23 -04:00
mainFeature.Execute();
2025-10-06 15:25:11 -04:00
break;
2023-10-10 15:15:42 -04:00
}
}
2025-10-06 11:00:59 -04:00
/// <summary>
/// Create the command set for the program
/// </summary>
2025-10-06 16:34:19 -04:00
private static CommandSet CreateCommands(MainFeature mainFeature)
2025-10-06 11:00:59 -04:00
{
List<string> header = [
"MPF.CLI [standalone|system] [options] <path> ...",
string.Empty,
];
List<string> footer = [
string.Empty,
"WARNING: Check will overwrite both any existing submission information files as well",
"as any log archives. Please make backups of those if you need to before running Check.",
string.Empty,
];
var commandSet = new CommandSet(header, footer);
// Standalone Options
commandSet.Add(new Help());
commandSet.Add(new VersionFeature());
commandSet.Add(new ListCodesFeature());
commandSet.Add(new ListMediaTypesFeature());
commandSet.Add(new ListSystemsFeature());
commandSet.Add(new ListProgramsFeature());
commandSet.Add(new InteractiveFeature());
// Check Options
2025-10-06 16:34:19 -04:00
commandSet.Add(mainFeature.UseInput);
commandSet.Add(mainFeature.LoadSeedInput);
commandSet.Add(mainFeature.NoPlaceholdersInput);
commandSet.Add(mainFeature.CreateIrdInput);
commandSet.Add(mainFeature.NoRetrieveInput);
2025-10-06 11:00:59 -04:00
// TODO: Figure out how to work with the credentials input
2025-10-06 16:34:19 -04:00
commandSet.Add(mainFeature.PullAllInput);
commandSet.Add(mainFeature.PathInput);
commandSet.Add(mainFeature.ScanInput);
commandSet.Add(mainFeature.DisableArchivesInput);
commandSet.Add(mainFeature.EnableDebugInput);
commandSet.Add(mainFeature.HideDriveLettersInput);
commandSet.Add(mainFeature.SuffixInput);
commandSet.Add(mainFeature.JsonInput);
commandSet.Add(mainFeature.IncludeArtifactsInput);
commandSet.Add(mainFeature.ZipInput);
commandSet.Add(mainFeature.DeleteInput);
2025-10-06 11:00:59 -04:00
return commandSet;
}
2019-04-04 00:37:17 -07:00
/// <summary>
2020-11-10 17:43:21 -08:00
/// Display help for MPF.Check
2019-04-04 00:37:17 -07:00
/// </summary>
/// <param name="error">Error string to prefix the help text with</param>
2025-10-06 16:06:23 -04:00
internal static void DisplayHelp(string? error = null)
{
if (error != null)
Console.WriteLine(error);
Console.WriteLine("Usage:");
Console.WriteLine("MPF.Check <system> [options] </path/to/output.cue/iso> ...");
Console.WriteLine();
2020-08-07 21:15:36 -07:00
Console.WriteLine("Standalone Options:");
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("lm, listmedia List supported media types");
Console.WriteLine("ls, listsystems List supported system types");
Console.WriteLine("lp, listprograms List supported dumping program outputs");
2025-10-06 10:32:16 -04:00
Console.WriteLine("i, interactive Enable interactive mode");
2020-05-07 14:23:49 -07:00
Console.WriteLine();
2020-08-07 21:15:36 -07:00
Console.WriteLine("Check Options:");
2024-06-25 16:48:24 -04:00
Console.WriteLine("-u, --use <program> Dumping program output type [REQUIRED]");
Console.WriteLine(" --load-seed <path> Load a seed submission JSON for user information");
Console.WriteLine(" --no-placeholders Disable placeholder values in submission info");
Console.WriteLine(" --create-ird Create IRD from output files (PS3 only)");
2025-06-02 09:35:26 -04:00
Console.WriteLine(" --no-retrieve Disable retrieving match information from Redump");
Console.WriteLine("-c, --credentials <user> <pw> Redump username and password (incompatible with --no-retrieve)");
Console.WriteLine(" --pull-all Pull all information from Redump (requires --credentials)");
2024-06-25 16:48:24 -04:00
Console.WriteLine("-p, --path <drivepath> Physical drive path for additional checks");
Console.WriteLine("-s, --scan Enable copy protection scan (requires --path)");
Console.WriteLine(" --disable-archives Disable scanning archives (requires --scan)");
Console.WriteLine(" --enable-debug Enable debug protection information (requires --scan)");
Console.WriteLine(" --hide-drive-letters Hide drive letters from scan output (requires --scan)");
2024-06-25 16:48:24 -04:00
Console.WriteLine("-x, --suffix Enable adding filename suffix");
Console.WriteLine("-j, --json Enable submission JSON output");
Console.WriteLine(" --include-artifacts Include artifacts in JSON (requires --json)");
2024-06-25 16:48:24 -04:00
Console.WriteLine("-z, --zip Enable log file compression");
Console.WriteLine("-d, --delete Enable unnecessary file deletion");
Console.WriteLine();
Console.WriteLine("WARNING: Check will overwrite both any existing submission information files as well");
Console.WriteLine("as any log archives. Please make backups of those if you need to before running Check.");
Console.WriteLine();
2024-06-25 16:48:24 -04:00
}
}
}