mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Slight cleanup of Help
This commit is contained in:
@@ -17,10 +17,10 @@ namespace SabreTools.Help
|
|||||||
#region Publicly facing variables
|
#region Publicly facing variables
|
||||||
|
|
||||||
public string? Name { get; protected set; }
|
public string? Name { get; protected set; }
|
||||||
public List<string> Flags { get; protected set; }
|
public readonly List<string> Flags = [];
|
||||||
public string? Description { get; protected set; }
|
public string? Description { get; protected set; }
|
||||||
public string? LongDescription { get; protected set; }
|
public string? LongDescription { get; protected set; }
|
||||||
public Dictionary<string, Feature?> Features { get; protected set; }
|
public readonly Dictionary<string, Feature?> Features = [];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -28,35 +28,28 @@ namespace SabreTools.Help
|
|||||||
|
|
||||||
public Feature()
|
public Feature()
|
||||||
{
|
{
|
||||||
|
_featureType = ParameterType.Flag;
|
||||||
Name = null;
|
Name = null;
|
||||||
Flags = [];
|
|
||||||
Description = null;
|
Description = null;
|
||||||
LongDescription = null;
|
LongDescription = null;
|
||||||
_featureType = ParameterType.Flag;
|
|
||||||
Features = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Feature(string name, string flag, string description, ParameterType featureType, string? longDescription = null)
|
public Feature(string name, string flag, string description, ParameterType featureType, string? longDescription = null)
|
||||||
{
|
{
|
||||||
|
_featureType = featureType;
|
||||||
Name = name;
|
Name = name;
|
||||||
Flags =
|
Flags.Add(flag);
|
||||||
[
|
|
||||||
flag
|
|
||||||
];
|
|
||||||
Description = description;
|
Description = description;
|
||||||
LongDescription = longDescription;
|
LongDescription = longDescription;
|
||||||
_featureType = featureType;
|
|
||||||
Features = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Feature(string name, List<string> flags, string description, ParameterType featureType, string? longDescription = null)
|
public Feature(string name, List<string> flags, string description, ParameterType featureType, string? longDescription = null)
|
||||||
{
|
{
|
||||||
|
_featureType = featureType;
|
||||||
Name = name;
|
Name = name;
|
||||||
Flags = flags;
|
Flags.AddRange(flags);
|
||||||
Description = description;
|
Description = description;
|
||||||
LongDescription = longDescription;
|
LongDescription = longDescription;
|
||||||
_featureType = featureType;
|
|
||||||
Features = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -87,7 +80,6 @@ namespace SabreTools.Help
|
|||||||
/// <param name="feature"></param>
|
/// <param name="feature"></param>
|
||||||
public void AddFeature(Feature feature)
|
public void AddFeature(Feature feature)
|
||||||
{
|
{
|
||||||
Features ??= [];
|
|
||||||
lock (Features)
|
lock (Features)
|
||||||
{
|
{
|
||||||
Features[feature.Name ?? string.Empty] = feature;
|
Features[feature.Name ?? string.Empty] = feature;
|
||||||
@@ -100,7 +92,6 @@ namespace SabreTools.Help
|
|||||||
/// <param name="flag">Flag to add for this feature</param>
|
/// <param name="flag">Flag to add for this feature</param>
|
||||||
public void AddFlag(string flag)
|
public void AddFlag(string flag)
|
||||||
{
|
{
|
||||||
Flags ??= [];
|
|
||||||
lock (Flags)
|
lock (Flags)
|
||||||
{
|
{
|
||||||
Flags.Add(flag);
|
Flags.Add(flag);
|
||||||
@@ -113,7 +104,6 @@ namespace SabreTools.Help
|
|||||||
/// <param name="flags">List of flags to add to this feature</param>
|
/// <param name="flags">List of flags to add to this feature</param>
|
||||||
public void AddFlags(List<string> flags)
|
public void AddFlags(List<string> flags)
|
||||||
{
|
{
|
||||||
Flags ??= [];
|
|
||||||
lock (Flags)
|
lock (Flags)
|
||||||
{
|
{
|
||||||
Flags.AddRange(flags);
|
Flags.AddRange(flags);
|
||||||
@@ -281,7 +271,7 @@ namespace SabreTools.Help
|
|||||||
public List<string> OutputRecursive(int tabLevel, int pre = 0, int midpoint = 0, bool includeLongDescription = false)
|
public List<string> OutputRecursive(int tabLevel, int pre = 0, int midpoint = 0, bool includeLongDescription = false)
|
||||||
{
|
{
|
||||||
// Create the output list
|
// Create the output list
|
||||||
List<string> outputList = new();
|
List<string> outputList = [];
|
||||||
|
|
||||||
// Build the output string first
|
// Build the output string first
|
||||||
string output = string.Empty;
|
string output = string.Empty;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ namespace SabreTools.Help
|
|||||||
{
|
{
|
||||||
#region Private variables
|
#region Private variables
|
||||||
|
|
||||||
private readonly List<string> _header;
|
private readonly List<string> _header = [];
|
||||||
private Dictionary<string, Feature?> _features;
|
private readonly Dictionary<string, Feature?> _features = [];
|
||||||
private const string _barrier = "-----------------------------------------";
|
private const string _barrier = "-----------------------------------------";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -18,14 +18,11 @@ namespace SabreTools.Help
|
|||||||
|
|
||||||
public FeatureSet()
|
public FeatureSet()
|
||||||
{
|
{
|
||||||
_header = [];
|
|
||||||
_features = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FeatureSet(List<string> header)
|
public FeatureSet(List<string> header)
|
||||||
{
|
{
|
||||||
_header = header;
|
_header.AddRange(header);
|
||||||
_features = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -36,7 +33,6 @@ namespace SabreTools.Help
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
_features ??= [];
|
|
||||||
if (!_features.ContainsKey(name))
|
if (!_features.ContainsKey(name))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -44,7 +40,6 @@ namespace SabreTools.Help
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_features ??= [];
|
|
||||||
_features[name] = value;
|
_features[name] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,7 +51,6 @@ namespace SabreTools.Help
|
|||||||
if (subfeature.Name == null)
|
if (subfeature.Name == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
_features ??= [];
|
|
||||||
if (!_features.ContainsKey(subfeature.Name))
|
if (!_features.ContainsKey(subfeature.Name))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -64,7 +58,6 @@ namespace SabreTools.Help
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_features ??= [];
|
|
||||||
if (subfeature.Name != null)
|
if (subfeature.Name != null)
|
||||||
_features[subfeature.Name] = value;
|
_features[subfeature.Name] = value;
|
||||||
}
|
}
|
||||||
@@ -79,7 +72,6 @@ namespace SabreTools.Help
|
|||||||
if (feature.Name == null)
|
if (feature.Name == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_features ??= [];
|
|
||||||
lock (_features)
|
lock (_features)
|
||||||
{
|
{
|
||||||
_features.Add(feature.Name, feature);
|
_features.Add(feature.Name, feature);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace SabreTools.Help
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of files, directories, and potential wildcard paths
|
/// List of files, directories, and potential wildcard paths
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> Inputs = [];
|
public readonly List<string> Inputs = [];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -50,32 +50,32 @@ namespace SabreTools.Help
|
|||||||
for (int i = 1; i < args.Length; i++)
|
for (int i = 1; i < args.Length; i++)
|
||||||
{
|
{
|
||||||
// Verify that the current flag is proper for the feature
|
// Verify that the current flag is proper for the feature
|
||||||
if (!ValidateInput(args[i]))
|
if (ValidateInput(args[i]))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Special precautions for files and directories
|
||||||
|
if (File.Exists(args[i]) || Directory.Exists(args[i]))
|
||||||
{
|
{
|
||||||
// Special precautions for files and directories
|
Inputs.Add(item: args[i]);
|
||||||
if (File.Exists(args[i]) || Directory.Exists(args[i]))
|
}
|
||||||
{
|
|
||||||
Inputs.Add(args[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Special precautions for wildcarded inputs (potential paths)
|
// Special precautions for wildcarded inputs (potential paths)
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
else if (args[i].Contains("*") || args[i].Contains("?"))
|
else if (args[i].Contains("*") || args[i].Contains("?"))
|
||||||
#else
|
#else
|
||||||
else if (args[i].Contains('*') || args[i].Contains('?'))
|
else if (args[i].Contains('*') || args[i].Contains('?'))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
Inputs.Add(args[i]);
|
Inputs.Add(args[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything else isn't a file
|
// Everything else isn't a file
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Error($"Invalid input detected: {args[i]}");
|
logger.Error($"Invalid input detected: {args[i]}");
|
||||||
help.OutputIndividualFeature(Name);
|
help.OutputIndividualFeature(Name);
|
||||||
LoggerImpl.Close();
|
LoggerImpl.Close();
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user