mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Remove this. references in Help
This commit is contained in:
@@ -28,35 +28,35 @@ namespace SabreTools.Help
|
|||||||
|
|
||||||
public Feature()
|
public Feature()
|
||||||
{
|
{
|
||||||
this.Name = null;
|
Name = null;
|
||||||
this.Flags = [];
|
Flags = [];
|
||||||
this.Description = null;
|
Description = null;
|
||||||
this.LongDescription = null;
|
LongDescription = null;
|
||||||
this._featureType = ParameterType.Flag;
|
_featureType = ParameterType.Flag;
|
||||||
this.Features = [];
|
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)
|
||||||
{
|
{
|
||||||
this.Name = name;
|
Name = name;
|
||||||
this.Flags =
|
Flags =
|
||||||
[
|
[
|
||||||
flag
|
flag
|
||||||
];
|
];
|
||||||
this.Description = description;
|
Description = description;
|
||||||
this.LongDescription = longDescription;
|
LongDescription = longDescription;
|
||||||
this._featureType = featureType;
|
_featureType = featureType;
|
||||||
this.Features = [];
|
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)
|
||||||
{
|
{
|
||||||
this.Name = name;
|
Name = name;
|
||||||
this.Flags = flags;
|
Flags = flags;
|
||||||
this.Description = description;
|
Description = description;
|
||||||
this.LongDescription = longDescription;
|
LongDescription = longDescription;
|
||||||
this._featureType = featureType;
|
_featureType = featureType;
|
||||||
this.Features = [];
|
Features = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -68,8 +68,8 @@ namespace SabreTools.Help
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Feature? this[string name]
|
public Feature? this[string name]
|
||||||
{
|
{
|
||||||
get { return this.Features.ContainsKey(name) ? this.Features[name] : null; }
|
get { return Features.ContainsKey(name) ? Features[name] : null; }
|
||||||
set { this.Features[name] = value; }
|
set { Features[name] = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -77,8 +77,8 @@ namespace SabreTools.Help
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Feature? this[Feature? subfeature]
|
public Feature? this[Feature? subfeature]
|
||||||
{
|
{
|
||||||
get { return this.Features.ContainsKey(subfeature?.Name ?? string.Empty) ? this.Features[subfeature?.Name ?? string.Empty] : null; }
|
get { return Features.ContainsKey(subfeature?.Name ?? string.Empty) ? Features[subfeature?.Name ?? string.Empty] : null; }
|
||||||
set { this.Features[subfeature?.Name ?? string.Empty] = value; }
|
set { Features[subfeature?.Name ?? string.Empty] = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -87,10 +87,10 @@ namespace SabreTools.Help
|
|||||||
/// <param name="feature"></param>
|
/// <param name="feature"></param>
|
||||||
public void AddFeature(Feature feature)
|
public void AddFeature(Feature feature)
|
||||||
{
|
{
|
||||||
this.Features ??= [];
|
Features ??= [];
|
||||||
lock (this.Features)
|
lock (Features)
|
||||||
{
|
{
|
||||||
this.Features[feature.Name ?? string.Empty] = feature;
|
Features[feature.Name ?? string.Empty] = feature;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,10 +100,10 @@ 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)
|
||||||
{
|
{
|
||||||
this.Flags ??= [];
|
Flags ??= [];
|
||||||
lock (this.Flags)
|
lock (Flags)
|
||||||
{
|
{
|
||||||
this.Flags.Add(flag);
|
Flags.Add(flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,10 +113,10 @@ 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)
|
||||||
{
|
{
|
||||||
this.Flags ??= [];
|
Flags ??= [];
|
||||||
lock (this.Flags)
|
lock (Flags)
|
||||||
{
|
{
|
||||||
this.Flags.AddRange(flags);
|
Flags.AddRange(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ namespace SabreTools.Help
|
|||||||
/// <returns>True if the flag was found, false otherwise</returns>
|
/// <returns>True if the flag was found, false otherwise</returns>
|
||||||
public bool ContainsFlag(string name)
|
public bool ContainsFlag(string name)
|
||||||
{
|
{
|
||||||
return this.Flags.Any(f => f == name || f.TrimStart('-') == name);
|
return Flags.Any(f => f == name || f.TrimStart('-') == name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -137,7 +137,7 @@ namespace SabreTools.Help
|
|||||||
/// <returns>True if the flag was found, false otherwise</returns>
|
/// <returns>True if the flag was found, false otherwise</returns>
|
||||||
public bool StartsWith(char c)
|
public bool StartsWith(char c)
|
||||||
{
|
{
|
||||||
return this.Flags.Any(f => f.TrimStart('-').ToLowerInvariant()[0] == c);
|
return Flags.Any(f => f.TrimStart('-').ToLowerInvariant()[0] == c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -162,8 +162,8 @@ namespace SabreTools.Help
|
|||||||
output += CreatePadding(pre);
|
output += CreatePadding(pre);
|
||||||
|
|
||||||
// Preprocess the flags, if necessary
|
// Preprocess the flags, if necessary
|
||||||
string[] newflags = new string[this.Flags.Count];
|
string[] newflags = new string[Flags.Count];
|
||||||
this.Flags.CopyTo(newflags);
|
Flags.CopyTo(newflags);
|
||||||
switch (_featureType)
|
switch (_featureType)
|
||||||
{
|
{
|
||||||
case ParameterType.Int32:
|
case ParameterType.Int32:
|
||||||
@@ -191,7 +191,7 @@ namespace SabreTools.Help
|
|||||||
output += " ";
|
output += " ";
|
||||||
|
|
||||||
// Append the description
|
// Append the description
|
||||||
output += this.Description;
|
output += Description;
|
||||||
|
|
||||||
// Now append it to the list
|
// Now append it to the list
|
||||||
outputList.Add(output);
|
outputList.Add(output);
|
||||||
@@ -206,7 +206,7 @@ namespace SabreTools.Help
|
|||||||
output = CreatePadding(pre + 4);
|
output = CreatePadding(pre + 4);
|
||||||
|
|
||||||
// Now split the input description and start processing
|
// Now split the input description and start processing
|
||||||
string[]? split = this.LongDescription?.Split(' ');
|
string[]? split = LongDescription?.Split(' ');
|
||||||
if (split == null)
|
if (split == null)
|
||||||
return outputList;
|
return outputList;
|
||||||
|
|
||||||
@@ -299,8 +299,8 @@ namespace SabreTools.Help
|
|||||||
output += CreatePadding(preAdjusted);
|
output += CreatePadding(preAdjusted);
|
||||||
|
|
||||||
// Preprocess the flags, if necessary
|
// Preprocess the flags, if necessary
|
||||||
string[] newflags = new string[this.Flags.Count];
|
string[] newflags = new string[Flags.Count];
|
||||||
this.Flags.CopyTo(newflags);
|
Flags.CopyTo(newflags);
|
||||||
switch (_featureType)
|
switch (_featureType)
|
||||||
{
|
{
|
||||||
case ParameterType.Int32:
|
case ParameterType.Int32:
|
||||||
@@ -328,7 +328,7 @@ namespace SabreTools.Help
|
|||||||
output += " ";
|
output += " ";
|
||||||
|
|
||||||
// Append the description
|
// Append the description
|
||||||
output += this.Description;
|
output += Description;
|
||||||
|
|
||||||
// Now append it to the list
|
// Now append it to the list
|
||||||
outputList.Add(output);
|
outputList.Add(output);
|
||||||
@@ -343,7 +343,7 @@ namespace SabreTools.Help
|
|||||||
output = CreatePadding(preAdjusted + 4);
|
output = CreatePadding(preAdjusted + 4);
|
||||||
|
|
||||||
// Now split the input description and start processing
|
// Now split the input description and start processing
|
||||||
string[]? split = this.LongDescription?.Split(' ');
|
string[]? split = LongDescription?.Split(' ');
|
||||||
if (split == null)
|
if (split == null)
|
||||||
return outputList;
|
return outputList;
|
||||||
|
|
||||||
@@ -396,9 +396,9 @@ namespace SabreTools.Help
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now let's append all subfeatures
|
// Now let's append all subfeatures
|
||||||
foreach (string feature in this.Features.Keys)
|
foreach (string feature in Features.Keys)
|
||||||
{
|
{
|
||||||
outputList.AddRange(this.Features[feature]!.OutputRecursive(tabLevel + 1, pre, midpoint, includeLongDescription));
|
outputList.AddRange(Features[feature]!.OutputRecursive(tabLevel + 1, pre, midpoint, includeLongDescription));
|
||||||
}
|
}
|
||||||
|
|
||||||
return outputList;
|
return outputList;
|
||||||
@@ -420,7 +420,7 @@ namespace SabreTools.Help
|
|||||||
{
|
{
|
||||||
// If we have a flag, make sure it doesn't have an equal sign in it
|
// If we have a flag, make sure it doesn't have an equal sign in it
|
||||||
case ParameterType.Flag:
|
case ParameterType.Flag:
|
||||||
valid = !input.Contains('=') && this.Flags.Contains(input);
|
valid = !input.Contains('=') && Flags.Contains(input);
|
||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
_value = true;
|
_value = true;
|
||||||
@@ -436,7 +436,7 @@ namespace SabreTools.Help
|
|||||||
|
|
||||||
// If we have an Int32, try to parse it if at all possible
|
// If we have an Int32, try to parse it if at all possible
|
||||||
case ParameterType.Int32:
|
case ParameterType.Int32:
|
||||||
valid = input.Contains('=') && this.Flags.Contains(input.Split('=')[0]);
|
valid = input.Contains('=') && Flags.Contains(input.Split('=')[0]);
|
||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
if (!Int32.TryParse(input.Split('=')[1], out int value))
|
if (!Int32.TryParse(input.Split('=')[1], out int value))
|
||||||
@@ -455,7 +455,7 @@ namespace SabreTools.Help
|
|||||||
|
|
||||||
// If we have an Int32, try to parse it if at all possible
|
// If we have an Int32, try to parse it if at all possible
|
||||||
case ParameterType.Int64:
|
case ParameterType.Int64:
|
||||||
valid = input.Contains('=') && this.Flags.Contains(input.Split('=')[0]);
|
valid = input.Contains('=') && Flags.Contains(input.Split('=')[0]);
|
||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
if (!Int64.TryParse(input.Split('=')[1], out long value))
|
if (!Int64.TryParse(input.Split('=')[1], out long value))
|
||||||
@@ -474,7 +474,7 @@ namespace SabreTools.Help
|
|||||||
|
|
||||||
// If we have an input, make sure it has an equals sign in it
|
// If we have an input, make sure it has an equals sign in it
|
||||||
case ParameterType.List:
|
case ParameterType.List:
|
||||||
valid = input.Contains('=') && this.Flags.Contains(input.Split('=')[0]);
|
valid = input.Contains('=') && Flags.Contains(input.Split('=')[0]);
|
||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
_value ??= new List<string>();
|
_value ??= new List<string>();
|
||||||
@@ -484,7 +484,7 @@ namespace SabreTools.Help
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ParameterType.String:
|
case ParameterType.String:
|
||||||
valid = input.Contains('=') && this.Flags.Contains(input.Split('=')[0]);
|
valid = input.Contains('=') && Flags.Contains(input.Split('=')[0]);
|
||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
_value = input.Split('=')[1];
|
_value = input.Split('=')[1];
|
||||||
@@ -501,7 +501,7 @@ namespace SabreTools.Help
|
|||||||
|
|
||||||
// If we haven't found a valid flag and we're not looking for just this feature, check to see if any of the subfeatures are valid
|
// If we haven't found a valid flag and we're not looking for just this feature, check to see if any of the subfeatures are valid
|
||||||
if (!valid && !exact)
|
if (!valid && !exact)
|
||||||
valid = this.Features.Keys.Any(k => this.Features[k]!.ValidateInput(input));
|
valid = Features.Keys.Any(k => Features[k]!.ValidateInput(input));
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace SabreTools.Help
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Error($"Invalid input detected: {args[i]}");
|
logger.Error($"Invalid input detected: {args[i]}");
|
||||||
help.OutputIndividualFeature(this.Name);
|
help.OutputIndividualFeature(Name);
|
||||||
LoggerImpl.Close();
|
LoggerImpl.Close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user