mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add universal changes to RombaSharp
This commit is contained in:
@@ -31,6 +31,9 @@ If -only-needed is set, only those files are put in the ROM archive that
|
||||
have a current entry in the DAT index.";
|
||||
Features = new Dictionary<string, SabreTools.Help.Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
|
||||
AddFeature(OnlyNeededFlag);
|
||||
AddFeature(ResumeStringInput);
|
||||
AddFeature(IncludeZipsInt32Input); // Defaults to 0
|
||||
|
||||
@@ -20,7 +20,18 @@ namespace RombaSharp.Features
|
||||
{
|
||||
internal class BaseFeature : TopLevel
|
||||
{
|
||||
#region Private Flag features
|
||||
#region Logging
|
||||
|
||||
/// <summary>
|
||||
/// Logging object
|
||||
/// </summary>
|
||||
protected Logger logger = new Logger();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Features
|
||||
|
||||
#region Flag features
|
||||
|
||||
internal const string CopyValue = "copy";
|
||||
internal static SabreTools.Help.Feature CopyFlag
|
||||
@@ -87,6 +98,20 @@ namespace RombaSharp.Features
|
||||
}
|
||||
}
|
||||
|
||||
internal const string ScriptValue = "script";
|
||||
internal static SabreTools.Help.Feature ScriptFlag
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SabreTools.Help.Feature(
|
||||
ScriptValue,
|
||||
new List<string>() { "-sc", "--script" },
|
||||
"Enable script mode (no clear screen)",
|
||||
ParameterType.Flag,
|
||||
"For times when RombaSharp is being used in a scripted environment, the user may not want the screen to be cleared every time that it is called. This flag allows the user to skip clearing the screen on run just like if the console was being redirected.");
|
||||
}
|
||||
}
|
||||
|
||||
internal const string SkipInitialScanValue = "skip-initial-scan";
|
||||
internal static SabreTools.Help.Feature SkipInitialScanFlag
|
||||
{
|
||||
@@ -115,7 +140,7 @@ namespace RombaSharp.Features
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Int32 features
|
||||
#region Int32 features
|
||||
|
||||
internal const string Include7ZipsInt32Value = "include-7zips";
|
||||
internal static SabreTools.Help.Feature Include7ZipsInt32Input
|
||||
@@ -184,7 +209,7 @@ namespace RombaSharp.Features
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Int64 features
|
||||
#region Int64 features
|
||||
|
||||
internal const string SizeInt64Value = "size";
|
||||
internal static SabreTools.Help.Feature SizeInt64Input
|
||||
@@ -201,7 +226,7 @@ namespace RombaSharp.Features
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private List<String> features
|
||||
#region List<String> features
|
||||
|
||||
internal const string DatsListStringValue = "dats";
|
||||
internal static SabreTools.Help.Feature DatsListStringInput
|
||||
@@ -231,7 +256,7 @@ namespace RombaSharp.Features
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private String features
|
||||
#region String features
|
||||
|
||||
internal const string BackupStringValue = "backup";
|
||||
internal static SabreTools.Help.Feature BackupStringInput
|
||||
@@ -259,6 +284,21 @@ namespace RombaSharp.Features
|
||||
}
|
||||
}
|
||||
|
||||
internal const string LogLevelStringValue = "log-level";
|
||||
internal static SabreTools.Help.Feature LogLevelStringInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SabreTools.Help.Feature(
|
||||
LogLevelStringValue,
|
||||
new List<string>() { "-ll", "--log-level" },
|
||||
"Set the lowest log level for output",
|
||||
ParameterType.String,
|
||||
longDescription: @"Set the lowest log level for output.
|
||||
Possible values are: Verbose, User, Warning, Error");
|
||||
}
|
||||
}
|
||||
|
||||
internal const string MissingSha1sStringValue = "missing-sha1s";
|
||||
internal static SabreTools.Help.Feature MissingSha1sStringInput
|
||||
{
|
||||
@@ -352,6 +392,24 @@ namespace RombaSharp.Features
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion // Features
|
||||
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Lowest log level for output
|
||||
/// </summary>
|
||||
public LogLevel LogLevel { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines if scripting mode is enabled
|
||||
/// </summary>
|
||||
public bool ScriptMode { get; protected set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Settings
|
||||
|
||||
// General settings
|
||||
internal static string _logdir; // Log folder location
|
||||
internal static string _tmpdir; // Temp folder location
|
||||
@@ -374,13 +432,26 @@ namespace RombaSharp.Features
|
||||
internal const string _config = "config.xml";
|
||||
internal static string _connectionString;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Add Feature Groups
|
||||
|
||||
/// <summary>
|
||||
/// Logging object
|
||||
/// Add common features
|
||||
/// </summary>
|
||||
protected Logger logger = new Logger();
|
||||
protected void AddCommonFeatures()
|
||||
{
|
||||
AddFeature(ScriptFlag);
|
||||
AddFeature(LogLevelStringInput);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override void ProcessFeatures(Dictionary<string, SabreTools.Help.Feature> features)
|
||||
{
|
||||
LogLevel = GetString(features, LogLevelStringValue).AsLogLevel();
|
||||
ScriptMode = GetBoolean(features, ScriptValue);
|
||||
|
||||
InitializeConfiguration();
|
||||
EnsureDatabase(_db, _connectionString);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ output dir. The files will be placed in the specified location using a folder
|
||||
structure according to the original DAT master directory tree structure.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
|
||||
AddFeature(OutStringInput);
|
||||
AddFeature(FixdatOnlyFlag);
|
||||
AddFeature(CopyFlag);
|
||||
|
||||
@@ -16,6 +16,9 @@ namespace RombaSharp.Features
|
||||
_featureType = ParameterType.Flag;
|
||||
LongDescription = "Cancels current long-running job.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
}
|
||||
|
||||
public override void ProcessFeatures(Dictionary<string, Feature> features)
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace RombaSharp.Features
|
||||
_featureType = ParameterType.Flag;
|
||||
LongDescription = "Print dat stats.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
}
|
||||
|
||||
public override void ProcessFeatures(Dictionary<string, Feature> features)
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace RombaSharp.Features
|
||||
_featureType = ParameterType.Flag;
|
||||
LongDescription = "Print db stats.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
}
|
||||
|
||||
public override void ProcessFeatures(Dictionary<string, Feature> features)
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace RombaSharp.Features
|
||||
in -old DAT file. Ignores those entries in -old that are not in -new.";
|
||||
this.Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
|
||||
AddFeature(OutStringInput);
|
||||
AddFeature(OldStringInput);
|
||||
AddFeature(NewStringInput);
|
||||
|
||||
@@ -23,6 +23,9 @@ namespace RombaSharp.Features
|
||||
LongDescription = "Creates a DAT file for the specified input directory and saves it to the -out filename.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
|
||||
AddFeature(OutStringInput);
|
||||
AddFeature(SourceStringInput);
|
||||
AddFeature(NameStringInput); // Defaults to "untitled"
|
||||
|
||||
@@ -21,6 +21,9 @@ namespace RombaSharp.Features
|
||||
LongDescription = @"Creates a DAT file with those entries that are in -new DAT files and not in -old DAT files. Ignores those entries in -old that are not in -new.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
|
||||
AddFeature(OutStringInput);
|
||||
AddFeature(OldStringInput);
|
||||
AddFeature(NewStringInput);
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace RombaSharp.Features
|
||||
_featureType = ParameterType.Flag;
|
||||
LongDescription = "Exports db to standardized export.csv";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
}
|
||||
|
||||
// TODO: Add ability to say which depot the files are found in
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace RombaSharp.Features
|
||||
LongDescription = @"For each specified DAT file it creates a fix DAT with the missing entries for that DAT. If nothing is missing it doesn't create a fix DAT for that particular DAT.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
|
||||
AddFeature(OutStringInput);
|
||||
AddFeature(FixdatOnlyFlag); // Enabled by default
|
||||
AddFeature(WorkersInt32Input);
|
||||
|
||||
@@ -21,6 +21,9 @@ namespace RombaSharp.Features
|
||||
_featureType = ParameterType.Flag;
|
||||
LongDescription = "Import a database from a formatted CSV file";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
}
|
||||
|
||||
public override void ProcessFeatures(Dictionary<string, Feature> features)
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace RombaSharp.Features
|
||||
LongDescription = "For each specified hash it looks up any available information (dat or rom).";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
|
||||
AddFeature(SizeInt64Input); // Defaults to -1
|
||||
AddFeature(OutStringInput);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ namespace RombaSharp.Features
|
||||
_featureType = ParameterType.Flag;
|
||||
LongDescription = "Print memory stats.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
}
|
||||
|
||||
public override void ProcessFeatures(Dictionary<string, Feature> features)
|
||||
|
||||
@@ -20,6 +20,9 @@ namespace RombaSharp.Features
|
||||
LongDescription = "Merges specified depot into current depot.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
|
||||
AddFeature(OnlyNeededFlag);
|
||||
AddFeature(ResumeStringInput);
|
||||
AddFeature(WorkersInt32Input);
|
||||
|
||||
@@ -21,6 +21,9 @@ namespace RombaSharp.Features
|
||||
_featureType = ParameterType.Flag;
|
||||
LongDescription = "For each specified DAT file, create miss and have file";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
}
|
||||
|
||||
public override void ProcessFeatures(Dictionary<string, Feature> features)
|
||||
|
||||
@@ -16,6 +16,9 @@ namespace RombaSharp.Features
|
||||
_featureType = ParameterType.Flag;
|
||||
LongDescription = "Shows progress of the currently running command.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
}
|
||||
|
||||
public override void ProcessFeatures(Dictionary<string, Feature> features)
|
||||
|
||||
@@ -21,6 +21,9 @@ a folder structure according to the original DAT master directory tree
|
||||
structure. It also deletes the specified DATs from the DAT index.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
|
||||
AddFeature(BackupStringInput);
|
||||
AddFeature(WorkersInt32Input);
|
||||
AddFeature(DepotListStringInput);
|
||||
|
||||
@@ -22,6 +22,9 @@ a folder structure according to the original DAT master directory tree
|
||||
structure. It also deletes the specified DATs from the DAT index.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
|
||||
AddFeature(WorkersInt32Input);
|
||||
AddFeature(DepotListStringInput);
|
||||
AddFeature(DatsListStringInput);
|
||||
|
||||
@@ -30,6 +30,9 @@ accordingly, marking deleted or overwritten dats as orphaned and updating
|
||||
contents of any changed dats.";
|
||||
Features = new Dictionary<string, SabreTools.Help.Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
|
||||
AddFeature(WorkersInt32Input);
|
||||
AddFeature(MissingSha1sStringInput);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ namespace RombaSharp.Features
|
||||
_featureType = ParameterType.Flag;
|
||||
LongDescription = "Rescan a specific depot to get new information";
|
||||
Features = new Dictionary<string, SabreTools.Help.Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
}
|
||||
|
||||
public override void ProcessFeatures(Dictionary<string, SabreTools.Help.Feature> features)
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using SabreTools.Help;
|
||||
|
||||
namespace RombaSharp.Features
|
||||
{
|
||||
internal class Script : BaseFeature
|
||||
{
|
||||
public const string Value = "Script";
|
||||
|
||||
public Script()
|
||||
{
|
||||
Name = Value;
|
||||
Flags = new List<string>() { "--script" };
|
||||
Description = "Enable script mode (no clear screen)";
|
||||
_featureType = ParameterType.Flag;
|
||||
LongDescription = "For times when RombaSharp is being used in a scripted environment, the user may not want the screen to be cleared every time that it is called. This flag allows the user to skip clearing the screen on run just like if the console was being redirected.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,9 @@ namespace RombaSharp.Features
|
||||
_featureType = ParameterType.Flag;
|
||||
LongDescription = "Gracefully shuts down server saving all the cached data.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
}
|
||||
|
||||
public override void ProcessFeatures(Dictionary<string, Feature> features)
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace RombaSharp.Features
|
||||
_featureType = ParameterType.Flag;
|
||||
LongDescription = "Prints version.";
|
||||
Features = new Dictionary<string, Feature>();
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
}
|
||||
|
||||
public override void ProcessFeatures(Dictionary<string, Feature> features)
|
||||
|
||||
@@ -49,24 +49,6 @@ namespace RombaSharp
|
||||
// Create a new Help object for this program
|
||||
_help = RetrieveHelp();
|
||||
|
||||
// Get the location of the script tag, if it exists
|
||||
int scriptLocation = (new List<string>(args)).IndexOf("--script");
|
||||
|
||||
// If output is being redirected or we are in script mode, don't allow clear screens
|
||||
if (!Console.IsOutputRedirected && scriptLocation == -1)
|
||||
{
|
||||
Console.Clear();
|
||||
Prepare.SetConsoleHeader("RombaSharp");
|
||||
}
|
||||
|
||||
// Now we remove the script tag because it messes things up
|
||||
if (scriptLocation > -1)
|
||||
{
|
||||
List<string> newargs = new List<string>(args);
|
||||
newargs.RemoveAt(scriptLocation);
|
||||
args = newargs.ToArray();
|
||||
}
|
||||
|
||||
// Credits take precidence over all
|
||||
if ((new List<string>(args)).Contains("--credits"))
|
||||
{
|
||||
@@ -116,13 +98,22 @@ namespace RombaSharp
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the new log level based on settings
|
||||
LoggerImpl.LowestLogLevel = feature.LogLevel;
|
||||
|
||||
// If output is being redirected or we are in script mode, don't allow clear screens
|
||||
if (!Console.IsOutputRedirected && feature.ScriptMode)
|
||||
{
|
||||
Console.Clear();
|
||||
Prepare.SetConsoleHeader("SabreTools");
|
||||
}
|
||||
|
||||
// Now process the current feature
|
||||
Dictionary<string, Feature> features = _help.GetEnabledFeatures();
|
||||
switch (featureName)
|
||||
{
|
||||
case DisplayHelpDetailed.Value:
|
||||
case DisplayHelp.Value:
|
||||
case Script.Value:
|
||||
// No-op as this should be caught
|
||||
break;
|
||||
|
||||
@@ -189,7 +180,6 @@ namespace RombaSharp
|
||||
// Add all of the features
|
||||
help.Add(new DisplayHelp());
|
||||
help.Add(new DisplayHelpDetailed());
|
||||
help.Add(new Script());
|
||||
help.Add(new Archive());
|
||||
help.Add(new Build());
|
||||
help.Add(new Cancel());
|
||||
|
||||
@@ -96,6 +96,19 @@ with each flag. Not all features are currently available.
|
||||
|
||||
Usage:
|
||||
RombaSharp.exe [feature] [options] [filename|dirname] ...
|
||||
|
||||
Universal Options:
|
||||
These parameters can be enabled on any feature except Detailed Help and Help
|
||||
|
||||
-ll=, --log-level= Set the lowest log level for output
|
||||
Set the lowest log level for output.
|
||||
Possible values are: Verbose, User, Warning, Error
|
||||
|
||||
-sc, --script Enable script mode (no clear screen)
|
||||
For times when SabreTools is being used in a scripted environment, the
|
||||
user may not want the screen to be cleared every time that it is called.
|
||||
This flag allows the user to skip clearing the screen on run just like if
|
||||
the console was being redirected.
|
||||
|
||||
Features and Options:
|
||||
-?, -h, --help Show the built-in help text
|
||||
|
||||
Reference in New Issue
Block a user