2019-02-10 14:47:53 -08:00
|
|
|
|
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;
|
2019-02-10 14:47:53 -08:00
|
|
|
|
|
2020-11-10 17:43:21 -08:00
|
|
|
|
namespace MPF.Check
|
2019-02-10 14:47:53 -08:00
|
|
|
|
{
|
|
|
|
|
|
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-07 16:40:30 -04:00
|
|
|
|
BaseFeature.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
|
2025-10-07 16:40:30 -04:00
|
|
|
|
case Help: BaseFeature.DisplayHelp(); return;
|
2025-10-06 15:25:11 -04:00
|
|
|
|
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 17:53:15 -04:00
|
|
|
|
if (!interactive.ProcessArgs(args, 0))
|
|
|
|
|
|
{
|
2025-10-07 16:40:30 -04:00
|
|
|
|
BaseFeature.DisplayHelp();
|
2025-10-06 17:53:15 -04:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-10-07 16:40:30 -04:00
|
|
|
|
if (!interactive.VerifyInputs())
|
2025-10-06 17:53:15 -04:00
|
|
|
|
{
|
2025-10-07 16:40:30 -04:00
|
|
|
|
Console.Error.WriteLine("At least one input is required");
|
|
|
|
|
|
BaseFeature.DisplayHelp();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!interactive.Execute())
|
|
|
|
|
|
{
|
|
|
|
|
|
BaseFeature.DisplayHelp();
|
2025-10-06 17:53:15 -04:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-06 15:25:11 -04:00
|
|
|
|
break;
|
2025-04-30 16:49:28 -04:00
|
|
|
|
|
2025-10-06 15:25:11 -04:00
|
|
|
|
// Default Behavior
|
|
|
|
|
|
default:
|
2025-10-06 17:53:15 -04:00
|
|
|
|
if (!mainFeature.ProcessArgs(args, 0))
|
|
|
|
|
|
{
|
2025-10-07 16:40:30 -04:00
|
|
|
|
BaseFeature.DisplayHelp();
|
2025-10-06 17:53:15 -04:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-10-07 16:40:30 -04:00
|
|
|
|
if (!mainFeature.VerifyInputs())
|
2025-10-06 17:53:15 -04:00
|
|
|
|
{
|
2025-10-07 16:40:30 -04:00
|
|
|
|
Console.Error.WriteLine("At least one input is required");
|
|
|
|
|
|
BaseFeature.DisplayHelp();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (mainFeature.Execute())
|
|
|
|
|
|
{
|
|
|
|
|
|
BaseFeature.DisplayHelp();
|
2025-10-06 17:53:15 -04:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-06 15:25:11 -04:00
|
|
|
|
break;
|
2023-10-10 15:15:42 -04:00
|
|
|
|
}
|
2019-02-10 14:47:53 -08: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-02-10 14:47:53 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|