Make DICUI.Check better

This commit is contained in:
Matt Nadareski
2019-04-04 00:37:17 -07:00
parent 28f6d50e5a
commit 902e4e5715
3 changed files with 1258 additions and 56 deletions

View File

@@ -9,26 +9,60 @@ namespace DICUI.Check
{
public static void Main(string[] args)
{
if (args.Length < 2)
// Help options
if (args.Length == 0
|| args[0] == "/h" || args[0] == "/?"
|| args[0] == "-h" || args[0] == "-?")
{
DisplayHelp("Invalid number of arguments");
DisplayHelp();
return;
}
// Check for a valid mapped type and/or system
bool valid = MediaTypeFromString(args[0], out MediaType mediaType, out KnownSystem knownSystem);
if (!valid)
// List options
if (args[0] == "/lm" || args[0] == "/listmedia"
|| args[0] == "-lm" || args[0] == "--listmedia")
{
ListMediaTypes();
Console.ReadLine();
return;
}
else if (args[0] == "/ls" || args[0] == "/listsystems"
|| args[0] == "-ls" || args[0] == "--listsystems")
{
ListKnownSystems();
Console.ReadLine();
return;
}
// Normal operation check
if (args.Length < 3)
{
DisplayHelp("Invalid number of arguments");
return;
}
// Check the MediaType
var mediaType = Converters.StringToMediaType(args[0].Trim('"'));
if (mediaType == MediaType.NONE)
{
DisplayHelp($"{args[0]} is not a recognized media type");
return;
}
// Check the KnownSystem
var knownSystem = Converters.StringToKnownSystem(args[1].Trim('"'));
if (knownSystem == KnownSystem.NONE)
{
DisplayHelp($"{args[1]} is not a recognized system");
return;
}
// Make a new Progress object
var progress = new Progress<Result>();
progress.ProgressChanged += ProgressUpdated;
// Loop through all the rest of the args
for (int i = 1; i < args.Length; i++)
for (int i = 2; i < args.Length; i++)
{
// Check for a file
if (!File.Exists(args[i]))
@@ -54,72 +88,73 @@ namespace DICUI.Check
}
}
/// <summary>
/// Display help for DICUI.Check
/// </summary>
/// <param name="error">Error string to prefix the help text with</param>
private static void DisplayHelp(string error = null)
{
if (error != null)
Console.WriteLine(error);
Console.WriteLine("Usage:");
Console.WriteLine("DICUI.Check.exe <mediatype> </path/to/output.bin> ...");
Console.WriteLine("DICUI.Check.exe <mediatype> <system> </path/to/output.bin> ...");
Console.WriteLine();
Console.WriteLine(@"Media Types:\r\n
Console.WriteLine(@"Common Media Types:\r\n
bd / bluray - BD-ROM
cd / cdrom - CD-ROM
dvd - DVD-ROM
gd / gdrom - GD-ROM
hddvd - HD-DVD
bd / bluray - BD-ROM
fd / floppy - Floppy Disk
umd - UMD
xbox - XBOX DVD");
gd / gdrom - GD-ROM
umd - UMD");
Console.WriteLine("Run 'DICUI.Check.exe [-lm|--listmedia' for more options");
Console.WriteLine();
Console.WriteLine(@"Common Systems:\r\n
apple / mac - Apple Macintosh
cdi - Philips CD-i
ibm / ibmpc - IBM PC Compatible
psx / ps1 - Sony PlayStation
ps2 - Sony PlayStation 2
psp - Sony PlayStation Portable
saturn - Sega Saturn
xbox - Microsoft XBOX
x360 - Microsoft XBOX 360");
Console.WriteLine("Run 'DICUI.Check.exe [-ls|--listsystems' for more options");
}
private static bool MediaTypeFromString(string val, out MediaType type, out KnownSystem system)
/// <summary>
/// List all media types with their short usable names
/// </summary>
private static void ListMediaTypes()
{
switch (val.ToLowerInvariant())
Console.WriteLine("Supported Media Types:");
foreach (var val in Enum.GetValues(typeof(MediaType)))
{
case "cd":
case "cdrom":
type = MediaType.CDROM;
system = KnownSystem.IBMPCCompatible;
return true;
case "dvd":
type = MediaType.DVD;
system = KnownSystem.IBMPCCompatible;
return true;
case "gd":
case "gdrom":
type = MediaType.GDROM;
system = KnownSystem.SegaDreamcast;
return true;
case "hddvd":
type = MediaType.HDDVD;
system = KnownSystem.HDDVDVideo;
return true;
case "bd":
case "bluray":
type = MediaType.BluRay;
system = KnownSystem.BDVideo;
return true;
case "fd":
case "floppy":
type = MediaType.FloppyDisk;
system = KnownSystem.IBMPCCompatible;
return true;
case "umd":
type = MediaType.UMD;
system = KnownSystem.SonyPlayStationPortable;
return true;
case "xbox":
type = MediaType.DVD;
system = KnownSystem.MicrosoftXBOX;
return true;
default:
type = MediaType.NONE;
system = KnownSystem.NONE;
return false;
if (((MediaType)val) == MediaType.NONE)
continue;
Console.WriteLine($"{((MediaType?)val).ShortName()} - {((MediaType?)val).Name()}");
}
}
/// <summary>
/// List all known systems with their short usable names
/// </summary>
private static void ListKnownSystems()
{
Console.WriteLine("Supported Known Systems:");
foreach (var val in Enum.GetValues(typeof(KnownSystem)))
{
if (((KnownSystem)val) == KnownSystem.NONE)
continue;
Console.WriteLine($"{((KnownSystem?)val).ShortName()} - {((KnownSystem?)val).Name()}");
}
}
/// <summary>
/// Simple process counter to write to console
/// </summary>
private static void ProgressUpdated(object sender, Result value)
{
Console.WriteLine(value.Message);

File diff suppressed because it is too large Load Diff

View File

@@ -34,6 +34,11 @@ namespace DICUI.Utilities
return Converters.MediaTypeToString(type);
}
public static string ShortName(this MediaType? type)
{
return Converters.MediaTypeToShortString(type);
}
public static string Extension(this MediaType? type)
{
return Converters.MediaTypeToExtension(type);
@@ -67,6 +72,11 @@ namespace DICUI.Utilities
return Converters.KnownSystemToString(system);
}
public static string ShortName(this KnownSystem? system)
{
return Converters.KnownSystemToShortString(system);
}
public static KnownSystemCategory Category(this KnownSystem? system)
{
if (system < KnownSystem.MarkerConsoleEnd)