[SabreTools, Help] Misc improvemets and bug fixes

This commit is contained in:
Matt Nadareski
2017-02-02 16:40:37 -08:00
parent 9b2895228f
commit d5b6aee14d
2 changed files with 64 additions and 12 deletions

View File

@@ -32,8 +32,36 @@ namespace SabreTools.Helper.Help
public Feature this[string name] public Feature this[string name]
{ {
get { return _features[name]; } get
set { _features[name] = value; } {
if (_features == null)
{
_features = new Dictionary<string, Feature>();
}
if (!_features.ContainsKey(name))
{
return null;
}
return _features[name];
}
set
{
if (_features == null)
{
_features = new Dictionary<string, Feature>();
}
if (_features.ContainsKey(name))
{
_features[name] = value;
}
else
{
_features.Add(name, value);
}
}
} }
/// <summary> /// <summary>
@@ -59,25 +87,24 @@ namespace SabreTools.Helper.Help
#region Instance Methods #region Instance Methods
/// <summary> /// <summary>
/// Check if a flag is a top-level (main application) flag /// Get the feature name for a given flag or short name
/// </summary> /// </summary>
/// <param name="flag">Name of the flag to check</param> /// <returns>Feature name</returns>
/// <returns>True if the feature was found, false otherwise</returns> public string GetFeatureName(string name)
public bool TopLevelFlag(string flag)
{ {
bool success = false; string feature = "";
// Loop through the features and check // Loop through the features
foreach (string feature in _features.Keys) foreach (string featureName in _features.Keys)
{ {
if (_features[feature].ValidateInput(flag, exact: true)) if (_features[featureName].ValidateInput(name, exact: true))
{ {
success = true; feature = featureName;
break; break;
} }
} }
return success; return feature;
} }
/// <summary> /// <summary>
@@ -183,6 +210,28 @@ namespace SabreTools.Helper.Help
WriteOutWithPauses(output); WriteOutWithPauses(output);
} }
/// <summary>
/// Check if a flag is a top-level (main application) flag
/// </summary>
/// <param name="flag">Name of the flag to check</param>
/// <returns>True if the feature was found, false otherwise</returns>
public bool TopLevelFlag(string flag)
{
bool success = false;
// Loop through the features and check
foreach (string feature in _features.Keys)
{
if (_features[feature].ValidateInput(flag, exact: true))
{
success = true;
break;
}
}
return success;
}
/// <summary> /// <summary>
/// Write out the help text with pauses, if needed /// Write out the help text with pauses, if needed
/// </summary> /// </summary>

View File

@@ -258,6 +258,9 @@ namespace SabreTools
return; return;
} }
// Now get the proper name for the feature
feature = _help.GetFeatureName(feature);
// Determine which switches are enabled (with values if necessary) // Determine which switches are enabled (with values if necessary)
for (int i = 1; i < args.Length; i++) for (int i = 1; i < args.Length; i++)
{ {