Files
SabreTools/DatToMiss/DatToMiss.cs
Matt Nadareski d97573848b Errors all around
2016-04-20 14:24:38 -07:00

113 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using SabreTools.Helper;
namespace SabreTools
{
public class DatToMiss
{
private static Logger logger;
public static void Main(string[] args)
{
Console.Clear();
// Credits take precidence over all
if ((new List<string>(args)).Contains("--credits"))
{
Build.Credits();
return;
}
if (args.Length == 0)
{
Build.Help();
return;
}
logger = new Logger(false, "dattomiss.log");
logger.Start();
// Output the title
Build.Start("DatToMiss");
string prefix = "", postfix = "", input = "", addext = "", repext = "";
bool tofile = false, help = false, usegame = true, quotes = false;
foreach (string arg in args)
{
switch (arg)
{
case "-h":
case "-?":
case "--help":
help = true;
break;
case "-l":
case "--log":
tofile = true;
break;
case "-r":
case "--roms":
usegame = false;
break;
case "-q":
case "--quotes":
quotes = true;
break;
default:
if (arg.StartsWith("-pre=") || arg.StartsWith("--prefix="))
{
prefix = arg.Split('=')[1];
}
else if (arg.StartsWith("-post=") || arg.StartsWith("--postfix="))
{
postfix = arg.Split('=')[1];
}
else if (arg.StartsWith("-ae=") || arg.StartsWith("--add-ext="))
{
addext = arg.Split('=')[1];
}
else if (arg.StartsWith("-re=") || arg.StartsWith("--rep-ext="))
{
repext = arg.Split('=')[1];
}
else if (input == "" && File.Exists(arg.Replace("\"", "")))
{
input = arg.Replace("\"", "");
}
else
{
logger.Warning("Incorrect param or extra input found: " + arg + Environment.NewLine);
Build.Help();
logger.Close();
return;
}
break;
}
}
// Set the possibly new value for logger
logger.ToFile = tofile;
// Show help if explicitly asked for it or if not enough files are supplied
if (help || input == "")
{
Build.Help();
logger.Close();
return;
}
// Get the full input name
input = Path.GetFullPath(input);
// Get the output name
string name = Path.GetFileNameWithoutExtension(input) + "-miss.txt";
// Read in the roms from the DAT and then write them to the file
Output.WriteToText(name, Path.GetDirectoryName(input), RomManipulation.Parse(input, 0, 0, logger), logger, usegame, prefix, postfix, addext, repext, quotes);
}
}
}