mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[RombaSharp] Move RombaSharp to new Help system
This commit is contained in:
183
RombaSharp/Partials/RombaSharp.Help.cs
Normal file
183
RombaSharp/Partials/RombaSharp.Help.cs
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using SabreTools.Helper.Data;
|
||||||
|
using SabreTools.Helper.Help;
|
||||||
|
using SabreTools.Helper.Resources;
|
||||||
|
|
||||||
|
namespace RombaSharp
|
||||||
|
{
|
||||||
|
public partial class RombaSharp
|
||||||
|
{
|
||||||
|
public static Help RetrieveHelp()
|
||||||
|
{
|
||||||
|
// Create and add the header to the Help object
|
||||||
|
string barrier = "-----------------------------------------";
|
||||||
|
List<string> helpHeader = new List<string>();
|
||||||
|
helpHeader.Add(Resources.RombaSharp_Name + " - " + Resources.RombaSharp_Desc);
|
||||||
|
helpHeader.Add(barrier);
|
||||||
|
helpHeader.Add(Resources.Usage + ": " + Resources.RombaSharp_Name + " [option] [filename|dirname] ...");
|
||||||
|
helpHeader.Add("");
|
||||||
|
Help help = new Help(helpHeader);
|
||||||
|
|
||||||
|
// Create the Help feature
|
||||||
|
Feature helpFeature = new Feature(
|
||||||
|
new List<string>() { "-?", "-h", "--help" },
|
||||||
|
"Show this help",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// Create the Archive feature
|
||||||
|
Feature archive = new Feature(
|
||||||
|
"archive",
|
||||||
|
"Adds ROM files from the specified directories to depot",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
archive.AddFeature("only-needed", new Feature(
|
||||||
|
"-only-needed",
|
||||||
|
"Only archive ROM files in database",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null));
|
||||||
|
|
||||||
|
// Create the Build feature
|
||||||
|
Feature build = new Feature(
|
||||||
|
"build",
|
||||||
|
"For each specified DAT file it creates TZip files",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
build.AddFeature("copy", new Feature(
|
||||||
|
"-copy",
|
||||||
|
"Copy files instead of rebuilding",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null));
|
||||||
|
|
||||||
|
// Create the Stats feature
|
||||||
|
Feature stats = new Feature(
|
||||||
|
"dbstats",
|
||||||
|
"Prints db stats",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// Create the Rescan Depots feature
|
||||||
|
Feature rescanDepots = new Feature(
|
||||||
|
"depot-rescan",
|
||||||
|
"Rescan a specific depot to get new information",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// Create the Diffdat feature
|
||||||
|
Feature diffdat = new Feature(
|
||||||
|
"diffdat",
|
||||||
|
"Creates a DAT file for entries found in the new DAT",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
diffdat.AddFeature("new", new Feature(
|
||||||
|
"-new",
|
||||||
|
"DAT to compare to",
|
||||||
|
FeatureType.String,
|
||||||
|
null));
|
||||||
|
|
||||||
|
// Create the Dir2Dat feature
|
||||||
|
Feature dir2dat = new Feature(
|
||||||
|
"dir2dat",
|
||||||
|
"Creates a DAT file for the specified input directory",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
dir2dat.AddFeature("out", new Feature(
|
||||||
|
"-out",
|
||||||
|
"Filename to save out to",
|
||||||
|
FeatureType.String,
|
||||||
|
null));
|
||||||
|
|
||||||
|
// Create the Export feature
|
||||||
|
Feature export = new Feature(
|
||||||
|
"export",
|
||||||
|
"Exports db to export.csv",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// Create the Fixdat feature
|
||||||
|
Feature fixdat = new Feature(
|
||||||
|
"fixdat",
|
||||||
|
"For each specified DAT file it creates a fix DAT",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// Create the Lookup feature
|
||||||
|
Feature lookup = new Feature(
|
||||||
|
"lookup",
|
||||||
|
"For each specified hash, look up available information",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// Create the Mmmstats feature
|
||||||
|
Feature memstats = new Feature(
|
||||||
|
"memstats",
|
||||||
|
"Prints memory stats",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// Create the Miss feature
|
||||||
|
Feature miss = new Feature(
|
||||||
|
"miss",
|
||||||
|
"For each specified DAT file, create miss and have file",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// Create the Purge Backup feature
|
||||||
|
Feature purgeBackup = new Feature(
|
||||||
|
"purge-backup",
|
||||||
|
"Moves DAT index entries for orphaned DATs",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// Create the Purge Delete feature
|
||||||
|
Feature purgeDelete = new Feature(
|
||||||
|
"purge-delete",
|
||||||
|
"Deletes DAT index entries for orphaned DATs",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// Create the Refresh DATs feature
|
||||||
|
Feature refreshDats = new Feature(
|
||||||
|
"refresh-dats",
|
||||||
|
"Refreshes the DAT index from the files in the DAT root",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// Create the Progress feature
|
||||||
|
Feature progress = new Feature(
|
||||||
|
"progress",
|
||||||
|
"Shows progress of currently running command [OBSOLETE]",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// Create the Shutdown feature
|
||||||
|
Feature shutdown = new Feature(
|
||||||
|
"shutdown",
|
||||||
|
"Gracefully shuts down server [OBSOLETE]",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null);
|
||||||
|
|
||||||
|
// Now, add all of the main features to the Help object
|
||||||
|
help.Add("Help", helpFeature);
|
||||||
|
help.Add("Archive", archive);
|
||||||
|
help.Add("Build", build);
|
||||||
|
help.Add("Stats", stats);
|
||||||
|
help.Add("Rescan Depots", rescanDepots);
|
||||||
|
help.Add("Diffdat", diffdat);
|
||||||
|
help.Add("Dir2Dat", dir2dat);
|
||||||
|
help.Add("Export", export);
|
||||||
|
help.Add("Fixdat", fixdat);
|
||||||
|
help.Add("Lookup", lookup);
|
||||||
|
help.Add("Memstats", memstats);
|
||||||
|
help.Add("Miss", miss);
|
||||||
|
help.Add("Purge Backup", purgeBackup);
|
||||||
|
help.Add("Purge Delete", purgeDelete);
|
||||||
|
help.Add("Refresh DATs", refreshDats);
|
||||||
|
help.Add("Progress", progress);
|
||||||
|
help.Add("Shutdown", shutdown);
|
||||||
|
|
||||||
|
return help;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ using SearchOption = System.IO.SearchOption;
|
|||||||
using StreamWriter = System.IO.StreamWriter;
|
using StreamWriter = System.IO.StreamWriter;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace SabreTools
|
namespace RombaSharp
|
||||||
{
|
{
|
||||||
public partial class RombaSharp
|
public partial class RombaSharp
|
||||||
{
|
{
|
||||||
@@ -14,7 +14,7 @@ using System.IO;
|
|||||||
using Alphaleonis.Win32.Filesystem;
|
using Alphaleonis.Win32.Filesystem;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace SabreTools
|
namespace RombaSharp
|
||||||
{
|
{
|
||||||
public partial class RombaSharp
|
public partial class RombaSharp
|
||||||
{
|
{
|
||||||
@@ -3,9 +3,10 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
using SabreTools.Helper;
|
using SabreTools.Helper;
|
||||||
using SabreTools.Helper.Data;
|
using SabreTools.Helper.Data;
|
||||||
|
using SabreTools.Helper.Help;
|
||||||
using SabreTools.Helper.Tools;
|
using SabreTools.Helper.Tools;
|
||||||
|
|
||||||
namespace SabreTools
|
namespace RombaSharp
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Entry class for the RombaSharp application
|
/// Entry class for the RombaSharp application
|
||||||
@@ -36,6 +37,7 @@ namespace SabreTools
|
|||||||
private static string _dbSchema = "rombasharp";
|
private static string _dbSchema = "rombasharp";
|
||||||
private static string _connectionString;
|
private static string _connectionString;
|
||||||
private static Logger _logger;
|
private static Logger _logger;
|
||||||
|
private static Help _help;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Entry class for the RombaSharp application
|
/// Entry class for the RombaSharp application
|
||||||
@@ -44,9 +46,13 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
// Perform initial setup and verification
|
// Perform initial setup and verification
|
||||||
_logger = new Logger(true, "romba.log");
|
_logger = new Logger(true, "romba.log");
|
||||||
|
|
||||||
InitializeConfiguration();
|
InitializeConfiguration();
|
||||||
DatabaseTools.EnsureDatabase(_dbSchema, _db, _connectionString);
|
DatabaseTools.EnsureDatabase(_dbSchema, _db, _connectionString);
|
||||||
|
|
||||||
|
// Create a new Help object for this program
|
||||||
|
_help = RetrieveHelp();
|
||||||
|
|
||||||
// If output is being redirected, don't allow clear screens
|
// If output is being redirected, don't allow clear screens
|
||||||
if (!Console.IsOutputRedirected)
|
if (!Console.IsOutputRedirected)
|
||||||
{
|
{
|
||||||
@@ -64,14 +70,13 @@ namespace SabreTools
|
|||||||
// If there's no arguments, show help
|
// If there's no arguments, show help
|
||||||
if (args.Length == 0)
|
if (args.Length == 0)
|
||||||
{
|
{
|
||||||
Build.Help("RombaSharp");
|
_help.OutputGenericHelp();
|
||||||
_logger.Close();
|
_logger.Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Feature flags
|
// Feature flags
|
||||||
bool help = false,
|
bool archive = false,
|
||||||
archive = false,
|
|
||||||
build = false,
|
build = false,
|
||||||
dbstats = false,
|
dbstats = false,
|
||||||
depotRescan = false,
|
depotRescan = false,
|
||||||
@@ -106,8 +111,15 @@ namespace SabreTools
|
|||||||
case "-?":
|
case "-?":
|
||||||
case "-h":
|
case "-h":
|
||||||
case "--help":
|
case "--help":
|
||||||
help = true;
|
if (i + 1 < args.Length)
|
||||||
break;
|
{
|
||||||
|
_help.OutputIndividualFeature(args[i + 1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_help.OutputGenericHelp();
|
||||||
|
}
|
||||||
|
return;
|
||||||
case "archive":
|
case "archive":
|
||||||
archive = true;
|
archive = true;
|
||||||
break;
|
break;
|
||||||
@@ -212,20 +224,12 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If help is set, show the help screen
|
|
||||||
if (help)
|
|
||||||
{
|
|
||||||
Build.Help("RombaSharp");
|
|
||||||
_logger.Close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If more than one switch is enabled, show the help screen
|
// If more than one switch is enabled, show the help screen
|
||||||
if (!(archive ^ build ^ dbstats ^ depotRescan ^ diffdat ^ dir2dat ^ export ^ fixdat ^ lookup ^
|
if (!(archive ^ build ^ dbstats ^ depotRescan ^ diffdat ^ dir2dat ^ export ^ fixdat ^ lookup ^
|
||||||
memstats ^ miss ^ progress ^ purgeBackup ^ purgeDelete ^ refreshDats ^ shutdown))
|
memstats ^ miss ^ progress ^ purgeBackup ^ purgeDelete ^ refreshDats ^ shutdown))
|
||||||
{
|
{
|
||||||
_logger.Error("Only one feature switch is allowed at a time");
|
_logger.Error("Only one feature switch is allowed at a time");
|
||||||
Build.Help("RombaSharp");
|
_help.OutputGenericHelp();
|
||||||
_logger.Close();
|
_logger.Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -234,7 +238,7 @@ namespace SabreTools
|
|||||||
if (inputs.Count == 0 && (archive || build || depotRescan || dir2dat || fixdat || lookup || miss))
|
if (inputs.Count == 0 && (archive || build || depotRescan || dir2dat || fixdat || lookup || miss))
|
||||||
{
|
{
|
||||||
_logger.Error("This feature requires at least one input");
|
_logger.Error("This feature requires at least one input");
|
||||||
Build.Help("RombaSharp");
|
_help.OutputGenericHelp();
|
||||||
_logger.Close();
|
_logger.Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -343,7 +347,7 @@ namespace SabreTools
|
|||||||
// If nothing is set, show the help
|
// If nothing is set, show the help
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Build.Help("RombaSharp");
|
_help.OutputGenericHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Close();
|
_logger.Close();
|
||||||
|
|||||||
@@ -99,8 +99,9 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Partials\RombaSharp_Helpers.cs" />
|
<Compile Include="Partials\RombaSharp.Help.cs" />
|
||||||
<Compile Include="Partials\RombaSharp_Inits.cs" />
|
<Compile Include="Partials\RombaSharp.Helpers.cs" />
|
||||||
|
<Compile Include="Partials\RombaSharp.Inits.cs" />
|
||||||
<Compile Include="RombaSharp.cs" />
|
<Compile Include="RombaSharp.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user