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

@@ -59,42 +59,102 @@ namespace SabreTools
log = false, genall = false, add = false, rem = false, skip = false; log = false, genall = false, add = false, rem = false, skip = false;
string systems = "", sources = "", input = "", manu = "", url = "", outdir = ""; string systems = "", sources = "", input = "", manu = "", url = "", outdir = "";
foreach (string arg in args) foreach (string arg in args)
{
switch (arg)
{ {
// Main functions // Main functions
help = help || (arg == "-h" || arg == "-?" || arg == "--help"); case "-h":
import = import || (arg == "-i" || arg == "--import"); case "-?":
generate = generate || (arg == "-g" || arg == "--generate"); case "--help":
genall = genall || (arg == "-ga" || arg == "--generate-all"); help = true;
convertRV = convertRV || (arg == "-cr" || arg == "--convert-rv"); break;
convertXml = convertXml || (arg == "-cx" || arg == "--convert-xml"); case "-i":
listsys = listsys || (arg == "-lsy" || arg == "--list-systems"); case "--import":
listsrc = listsrc || (arg == "-lso" || arg == "--list-sources"); import = true;
add = add || (arg == "-a" || arg == "--add"); break;
rem = rem || (arg == "-r" || arg == "--remove"); 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 // User input strings
systems = (arg.StartsWith("system=") && systems == "" ? arg.Split('=')[1] : systems); if (arg.StartsWith("system=") && systems == "")
sources = (arg.StartsWith("source=") && sources == "" ? arg.Split('=')[1] : sources); {
outdir = (arg.StartsWith("out=") && outdir == "" ? arg.Split('=')[1] : outdir); systems = arg.Split('=')[1];
manu = (arg.StartsWith("manu=") && manu == "" ? arg.Split('=')[1] : manu); }
url = (arg.StartsWith("url=") && url == "" ? arg.Split('=')[1] : url); 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];
}
// Take care of the two distinct input name possibilites; prioritize the input tag // Take care of the two distinct input name possibilites; prioritize the input tag
input = (arg.StartsWith("input=") && input == "" ? arg.Split('=')[1] : input); else if (arg.StartsWith("input=") && input == "")
input = (!arg.StartsWith("-") && {
!arg.StartsWith("source=") && input = arg.Split('=')[1];
!arg.StartsWith("system=") && }
!arg.StartsWith("out=") && else if (input == "")
!arg.StartsWith("manu=") && {
!arg.StartsWith("url=") && input = arg;
!arg.StartsWith("input=") && }
input == "" ? arg : input); break;
}
} }
// 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