mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Make the process in DATabaseTwo more akin to normal DATabase; add new switches
This commit is contained in:
@@ -53,8 +53,32 @@ namespace SabreTools
|
|||||||
_logger = new Logger(true, "database2.log");
|
_logger = new Logger(true, "database2.log");
|
||||||
_logger.Start();
|
_logger.Start();
|
||||||
|
|
||||||
|
Remapping.CreateRemappings();
|
||||||
|
Build.Start("DATabaseTwo");
|
||||||
|
|
||||||
|
// Perform initial database and folder setup
|
||||||
|
if (!Directory.Exists(_datroot))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(_datroot);
|
||||||
|
}
|
||||||
|
if (!Directory.Exists(_outroot))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(_outroot);
|
||||||
|
}
|
||||||
|
DBTools.EnsureDatabase(_dbName, _connectionString);
|
||||||
|
|
||||||
|
// If there's no arguments, show the menu
|
||||||
|
if (args.Length == 0)
|
||||||
|
{
|
||||||
|
_logger.ToFile = true;
|
||||||
|
ShowMainMenu();
|
||||||
|
_logger.Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Set all default values
|
// Set all default values
|
||||||
bool help = false,
|
bool help = false,
|
||||||
|
gen = false,
|
||||||
genall = false,
|
genall = false,
|
||||||
ignore = false,
|
ignore = false,
|
||||||
listsys = false,
|
listsys = false,
|
||||||
@@ -72,6 +96,10 @@ namespace SabreTools
|
|||||||
case "--help":
|
case "--help":
|
||||||
help = true;
|
help = true;
|
||||||
break;
|
break;
|
||||||
|
case "-g":
|
||||||
|
case "--generate":
|
||||||
|
gen = true;
|
||||||
|
break;
|
||||||
case "-ga":
|
case "-ga":
|
||||||
case "--generate-all":
|
case "--generate-all":
|
||||||
genall = true;
|
genall = true;
|
||||||
@@ -117,18 +145,6 @@ namespace SabreTools
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call initial setup because everything after here requires it
|
|
||||||
Import(ignore);
|
|
||||||
|
|
||||||
// If there's no arguments, show the menu
|
|
||||||
if (args.Length == 0)
|
|
||||||
{
|
|
||||||
_logger.ToFile = true;
|
|
||||||
ShowMainMenu();
|
|
||||||
_logger.Close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we want a list of systems
|
// If we want a list of systems
|
||||||
if (listsys)
|
if (listsys)
|
||||||
{
|
{
|
||||||
@@ -138,12 +154,14 @@ namespace SabreTools
|
|||||||
// If we want to generate all DATs
|
// If we want to generate all DATs
|
||||||
else if (genall)
|
else if (genall)
|
||||||
{
|
{
|
||||||
|
Import(ignore);
|
||||||
InitGenerateAll(norename, old);
|
InitGenerateAll(norename, old);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we want to generate a DAT
|
// If we want to generate a DAT
|
||||||
else
|
else if (gen)
|
||||||
{
|
{
|
||||||
|
Import(ignore);
|
||||||
InitGenerate(system, norename, old);
|
InitGenerate(system, norename, old);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,10 +186,11 @@ namespace SabreTools
|
|||||||
Make a selection:
|
Make a selection:
|
||||||
|
|
||||||
1) Show command line usage
|
1) Show command line usage
|
||||||
2) Generate System DATs
|
2) Check for new or changed DATs
|
||||||
3) List all available systems
|
3) Generate System DATs
|
||||||
4) " + (_logger.ToFile ? "Disable Logging" : "Enable Logging") + @"
|
4) List all available systems
|
||||||
5) Show credits
|
5) " + (_logger.ToFile ? "Disable Logging" : "Enable Logging") + @"
|
||||||
|
6) Show credits
|
||||||
X) Exit Program
|
X) Exit Program
|
||||||
");
|
");
|
||||||
Console.Write("Enter selection: ");
|
Console.Write("Enter selection: ");
|
||||||
@@ -186,19 +205,22 @@ Make a selection:
|
|||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
break;
|
break;
|
||||||
case "2":
|
case "2":
|
||||||
GenerateMenu();
|
ImportMenu();
|
||||||
break;
|
break;
|
||||||
case "3":
|
case "3":
|
||||||
|
GenerateMenu();
|
||||||
|
break;
|
||||||
|
case "4":
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Build.Start("DATabaseTwo");
|
Build.Start("DATabaseTwo");
|
||||||
ListSystems();
|
ListSystems();
|
||||||
Console.Write("\nPress any key to continue...");
|
Console.Write("\nPress any key to continue...");
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
break;
|
break;
|
||||||
case "4":
|
case "5":
|
||||||
_logger.ToFile = !_logger.ToFile;
|
_logger.ToFile = !_logger.ToFile;
|
||||||
break;
|
break;
|
||||||
case "5":
|
case "6":
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Build.Credits();
|
Build.Credits();
|
||||||
Console.Write("\nPress any key to continue...");
|
Console.Write("\nPress any key to continue...");
|
||||||
@@ -208,6 +230,44 @@ Make a selection:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Show the text-based import menu
|
||||||
|
/// </summary>
|
||||||
|
private static void ImportMenu()
|
||||||
|
{
|
||||||
|
string selection = "";
|
||||||
|
bool ignore = false;
|
||||||
|
while (selection.ToLowerInvariant() != "b")
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
|
Build.Start("DATabaseTwo");
|
||||||
|
Console.WriteLine(@"IMPORT MENU
|
||||||
|
===========================
|
||||||
|
Make a selection:
|
||||||
|
|
||||||
|
1) " + (ignore ? "Enable new source prompt" : "Disable new source prompt") + @"
|
||||||
|
2) Begin import process
|
||||||
|
B) Go back to the previous menu
|
||||||
|
");
|
||||||
|
Console.Write("Enter selection: ");
|
||||||
|
selection = Console.ReadLine();
|
||||||
|
switch (selection)
|
||||||
|
{
|
||||||
|
case "1":
|
||||||
|
ignore = !ignore;
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
Console.Clear();
|
||||||
|
Import(ignore);
|
||||||
|
Console.Write("\nPress any key to continue...");
|
||||||
|
Console.ReadKey();
|
||||||
|
ignore = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Show the text-based generate menu
|
/// Show the text-based generate menu
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -218,7 +278,7 @@ Make a selection:
|
|||||||
while (selection.ToLowerInvariant() != "b")
|
while (selection.ToLowerInvariant() != "b")
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Build.Start("DATabase");
|
Build.Start("DATabaseTwo");
|
||||||
Console.WriteLine(@"GENERATE MENU
|
Console.WriteLine(@"GENERATE MENU
|
||||||
===========================
|
===========================
|
||||||
Make a selection:
|
Make a selection:
|
||||||
@@ -515,28 +575,12 @@ ORDER BY system.manufacturer, system.name";
|
|||||||
#region Helper Methods
|
#region Helper Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Perform initial setup for the program
|
/// Perform initial or incremental import of DATs in the root folder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ignore">False if each DAT that has no defined source asks for user input (default), true otherwise</param>
|
/// <param name="ignore">False if each DAT that has no defined source asks for user input (default), true otherwise</param>
|
||||||
private static void Import(bool ignore = false)
|
private static void Import(bool ignore = false)
|
||||||
{
|
{
|
||||||
Remapping.CreateRemappings();
|
_logger.Log("Beginning import/update process");
|
||||||
Build.Start("DATabaseTwo");
|
|
||||||
|
|
||||||
_logger.Log("Beginning setup...");
|
|
||||||
|
|
||||||
// Perform initial database and folder setup
|
|
||||||
if (!Directory.Exists(_datroot))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(_datroot);
|
|
||||||
}
|
|
||||||
if (!Directory.Exists(_outroot))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(_outroot);
|
|
||||||
}
|
|
||||||
|
|
||||||
DBTools.EnsureDatabase(_dbName, _connectionString);
|
|
||||||
|
|
||||||
using (SqliteConnection dbc = new SqliteConnection(_connectionString))
|
using (SqliteConnection dbc = new SqliteConnection(_connectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
@@ -706,7 +750,7 @@ VALUES (" + hashid + ", 'source', '" + sourceid + @"'),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Log("Setup complete!");
|
_logger.Log("Import/update process complete!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ Usage: DATabaseTwo [options]
|
|||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, -?, --help Show this help dialog
|
-h, -?, --help Show this help dialog
|
||||||
|
-g, --generate Start tool in generate mode
|
||||||
-ga, --generate-all Start tool in generate all mode
|
-ga, --generate-all Start tool in generate all mode
|
||||||
-i, --ignore Don't prompt for new sources
|
-i, --ignore Don't prompt for new sources
|
||||||
-lsy, --list-systems List all systems (id <= name)
|
-lsy, --list-systems List all systems (id <= name)
|
||||||
|
|||||||
Reference in New Issue
Block a user