Switch statement is more clear

I used this format for DATFromDir and it's much cleaner and easier to both read and comment. All should be like this.
This commit is contained in:
Matt Nadareski
2016-04-19 01:57:29 -07:00
parent 49d4ee818f
commit 14b21ff74c

View File

@@ -60,41 +60,101 @@ namespace SabreTools
string systems = "", sources = "", input = "", manu = "", url = "", outdir = ""; string systems = "", sources = "", input = "", manu = "", url = "", outdir = "";
foreach (string arg in args) foreach (string arg in args)
{ {
// Main functions switch (arg)
help = help || (arg == "-h" || arg == "-?" || arg == "--help"); {
import = import || (arg == "-i" || arg == "--import"); // Main functions
generate = generate || (arg == "-g" || arg == "--generate"); case "-h":
genall = genall || (arg == "-ga" || arg == "--generate-all"); case "-?":
convertRV = convertRV || (arg == "-cr" || arg == "--convert-rv"); case "--help":
convertXml = convertXml || (arg == "-cx" || arg == "--convert-xml"); help = true;
listsys = listsys || (arg == "-lsy" || arg == "--list-systems"); break;
listsrc = listsrc || (arg == "-lso" || arg == "--list-sources"); case "-i":
add = add || (arg == "-a" || arg == "--add"); case "--import":
rem = rem || (arg == "-r" || arg == "--remove"); import = true;
break;
case "-g":
case "--generate":
generate = true;
break;
case "-ga":
case "--generate-all":
genall = true;
break;
case "-cr":
case "--convert-rv":
convertRV = true;
break;
case "-cx":
case "--convert-xml":
convertXml = true;
break;
case "-lsy":
case "--list-systems":
listsys = true;
break;
case "-lso":
case "--list-sources":
listsrc = true;
break;
case "-a":
case "--add":
add = true;
break;
case "-r":
case "--remove":
rem = true;
break;
// Switches // Switches
log = log || (arg == "-l" || arg == "--log"); case "-l":
old = old || (arg == "-old" || arg == "--romvault"); case "--log":
norename = norename || (arg == "-nr" || arg == "--no-rename"); log = true;
skip = skip || (arg == "--skip"); break;
case "-old":
case "--romvault":
old = true;
break;
case "-nr":
case "--no-rename":
norename = true;
break;
case "--skip":
skip = true;
break;
default:
// User input strings
if (arg.StartsWith("system=") && systems == "")
{
systems = arg.Split('=')[1];
}
else if (arg.StartsWith("source=") && sources == "")
{
sources = arg.Split('=')[1];
}
else if (arg.StartsWith("out=") && outdir == "")
{
outdir = arg.Split('=')[1];
}
else if (arg.StartsWith("manu=") && manu == "")
{
manu = arg.Split('=')[1];
}
else if (arg.StartsWith("url=") && url == "")
{
url = arg.Split('=')[1];
}
// User input strings // Take care of the two distinct input name possibilites; prioritize the input tag
systems = (arg.StartsWith("system=") && systems == "" ? arg.Split('=')[1] : systems); else if (arg.StartsWith("input=") && input == "")
sources = (arg.StartsWith("source=") && sources == "" ? arg.Split('=')[1] : sources); {
outdir = (arg.StartsWith("out=") && outdir == "" ? arg.Split('=')[1] : outdir); input = arg.Split('=')[1];
manu = (arg.StartsWith("manu=") && manu == "" ? arg.Split('=')[1] : manu); }
url = (arg.StartsWith("url=") && url == "" ? arg.Split('=')[1] : url); else if (input == "")
{
// Take care of the two distinct input name possibilites; prioritize the input tag input = arg;
input = (arg.StartsWith("input=") && input == "" ? arg.Split('=')[1] : input); }
input = (!arg.StartsWith("-") && break;
!arg.StartsWith("source=") && }
!arg.StartsWith("system=") &&
!arg.StartsWith("out=") &&
!arg.StartsWith("manu=") &&
!arg.StartsWith("url=") &&
!arg.StartsWith("input=") &&
input == "" ? arg : input);
} }
// If skip is set, it's being called from the UI so we just exit // If skip is set, it's being called from the UI so we just exit