[DATFromDir] Remove Main method

This commit is contained in:
Matt Nadareski
2016-06-11 15:48:05 -07:00
parent 03daf21c39
commit 37916ef19b

View File

@@ -61,162 +61,6 @@ namespace SabreTools
_logger = logger;
}
/// <summary>
/// Start help or use supplied parameters
/// </summary>
/// <param name="args">String array representing command line parameters</param>
public static void Main(string[] args)
{
// If output is being redirected, don't allow clear screens
if (!Console.IsOutputRedirected)
{
Console.Clear();
}
// Credits take precidence over all
if ((new List<string>(args)).Contains("--credits"))
{
Build.Credits();
return;
}
Logger logger = new Logger(true, "datfromdir.log");
logger.Start();
// First things first, take care of all of the arguments that this could have
bool noMD5 = false, noSHA1 = false, forceunpack = false, archivesAsFiles = false, old = false, superDat = false, bare = false, romba = false, enableGzip = false;
string name = "", desc = "", cat = "", version = "", author = "", tempDir = "";
List<string> inputs = new List<string>();
foreach (string arg in args)
{
switch (arg)
{
case "-h":
case "-?":
case "--help":
Build.Help();
logger.Close();
return;
case "-b":
case "--bare":
bare = true;
break;
case "-f":
case "--files":
archivesAsFiles = true;
break;
case "-gz":
case "--gz-files":
enableGzip = true;
break;
case "-nm":
case "--noMD5":
noMD5 = true;
break;
case "-o":
case "--old":
old = true;
break;
case "-ro":
case "--romba":
romba = true;
break;
case "-s":
case "--noSHA1":
noSHA1 = true;
break;
case "-sd":
case "--superdat":
superDat = true;
break;
case "-u":
case "--unzip":
forceunpack = true;
break;
default:
if (arg.StartsWith("-n=") || arg.StartsWith("--name="))
{
name = arg.Split('=')[1];
}
else if (arg.StartsWith("-d=") || arg.StartsWith("--desc="))
{
desc = arg.Split('=')[1];
}
else if (arg.StartsWith("-c=") || arg.StartsWith("--cat="))
{
cat = arg.Split('=')[1];
}
else if (arg.StartsWith("-au=") || arg.StartsWith("--author="))
{
author = arg.Split('=')[1];
}
else if (arg.StartsWith("-t=") || arg.StartsWith("--temp="))
{
tempDir = arg.Split('=')[1];
}
else if (arg.StartsWith("-v=") || arg.StartsWith("--version="))
{
version = arg.Split('=')[1];
}
else
{
inputs.Add(arg);
}
break;
}
}
// If there's no inputs, show the help
if (inputs.Count == 0)
{
Build.Help();
logger.Close();
return;
}
// Output the title
Build.Start("DATFromDir");
// If any of the inputs are not valid, show the help
foreach (string input in inputs)
{
if (!File.Exists(input) && !Directory.Exists(input))
{
logger.Error(input + " is not a valid input!");
Console.WriteLine();
Build.Help();
return;
}
}
// Create a new DATFromDir object and process the inputs
DatData datdata = new DatData
{
Name = name,
Description = desc,
Category = cat,
Version = version,
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Author = author,
ForcePacking = (forceunpack ? ForcePacking.Unzip : ForcePacking.None),
OutputFormat = (old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
Romba = romba,
Type = (superDat ? "SuperDAT" : ""),
Roms = new Dictionary<string, List<RomData>>(),
};
DATFromDir dfd = new DATFromDir(inputs, datdata, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempDir, logger);
bool success = dfd.Start();
// If we failed, show the help
if (!success)
{
Console.WriteLine();
Build.Help();
}
logger.Close();
}
/// <summary>
/// Process the file, folder, or list of some combination into a DAT file
/// </summary>