mirror of
https://github.com/SabreTools/SabreTools.CommandLine.git
synced 2026-07-09 02:07:42 +00:00
Rename TopLevelFlag to IsTopLevel and clean up wording
This commit is contained in:
@@ -72,7 +72,7 @@ namespace SabreTools.CommandLine.Test
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TopLevelFlagTest()
|
||||
public void IsTopLevelTest()
|
||||
{
|
||||
var input1 = new FlagInput("input1", "--input1", "input1");
|
||||
var input2 = new FlagInput("input2", "--input2", "input2");
|
||||
@@ -81,13 +81,13 @@ namespace SabreTools.CommandLine.Test
|
||||
featureSet.Add(input1);
|
||||
featureSet.Add(input2);
|
||||
|
||||
bool actualTop1 = featureSet.TopLevelFlag("input1");
|
||||
bool actualTop1 = featureSet.IsTopLevel("input1");
|
||||
Assert.True(actualTop1);
|
||||
|
||||
bool actualTop2 = featureSet.TopLevelFlag("--input2");
|
||||
bool actualTop2 = featureSet.IsTopLevel("--input2");
|
||||
Assert.True(actualTop2);
|
||||
|
||||
bool actualTop3 = featureSet.TopLevelFlag("input3");
|
||||
bool actualTop3 = featureSet.IsTopLevel("input3");
|
||||
Assert.False(actualTop3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,10 +106,12 @@ namespace SabreTools.CommandLine
|
||||
/// <summary>
|
||||
/// Get the input name for a given flag or short name
|
||||
/// </summary>
|
||||
public string GetInputName(string name)
|
||||
/// <param name="value">Name or flag value to match</param>
|
||||
/// <returns>User input name on success, empty string on error</returns>
|
||||
public string GetInputName(string value)
|
||||
{
|
||||
// Pre-split the input for efficiency
|
||||
string[] splitInput = name.Split('=');
|
||||
string[] splitInput = value.Split('=');
|
||||
|
||||
foreach (var key in _inputs.Keys)
|
||||
{
|
||||
@@ -147,12 +149,12 @@ namespace SabreTools.CommandLine
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a flag is a top-level (main application) flag
|
||||
/// Check if a value is a direct child input
|
||||
/// </summary>
|
||||
/// <param name="flag">Name of the flag to check</param>
|
||||
/// <param name="value">Name or flag value to match</param>
|
||||
/// <returns>True if the feature was found, false otherwise</returns>
|
||||
public bool TopLevelFlag(string flag)
|
||||
=> GetInputName(flag).Length > 0;
|
||||
public bool IsTopLevel(string value)
|
||||
=> GetInputName(value).Length > 0;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -232,7 +234,7 @@ namespace SabreTools.CommandLine
|
||||
}
|
||||
|
||||
// If a top-level input is found
|
||||
if (TopLevelFlag(featureName!))
|
||||
if (IsTopLevel(featureName!))
|
||||
{
|
||||
// Retrieve the input
|
||||
featureName = GetInputName(featureName!);
|
||||
|
||||
Reference in New Issue
Block a user