mirror of
https://github.com/SabreTools/SabreTools.CommandLine.git
synced 2026-02-17 21:47:58 +00:00
Allow nested searches for feature values
This commit is contained in:
@@ -188,7 +188,7 @@ namespace SabreTools.CommandLine.Test
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFeature_NestedExists_Null()
|
||||
public void GetFeature_NestedExists_Returns()
|
||||
{
|
||||
var commandSet = new CommandSet();
|
||||
var child = new MockUserInput("b", "b", "b");
|
||||
@@ -200,7 +200,9 @@ namespace SabreTools.CommandLine.Test
|
||||
subChild.ProcessInput(["c"], ref index);
|
||||
|
||||
Feature? actual = commandSet.GetFeature("c");
|
||||
Assert.Null(actual);
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal("c", actual.Name);
|
||||
Assert.True(actual.Value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace SabreTools.CommandLine.Test.Inputs
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFeature_NestedExists_Null()
|
||||
public void GetFeature_NestedExists_Returns()
|
||||
{
|
||||
UserInput userInput = new MockUserInput("a", "a", "a");
|
||||
var child = new MockUserInput("b", "b", "b");
|
||||
@@ -166,7 +166,9 @@ namespace SabreTools.CommandLine.Test.Inputs
|
||||
subChild.ProcessInput(["c"], ref index);
|
||||
|
||||
Feature? actual = userInput.GetFeature("c");
|
||||
Assert.Null(actual);
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal("c", actual.Name);
|
||||
Assert.True(actual.Value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -325,7 +325,13 @@ namespace SabreTools.CommandLine
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Investigate if nested features should be supported
|
||||
// Check all children recursively
|
||||
foreach (var child in _inputs.Values)
|
||||
{
|
||||
if (child.TryGetFeature(key, out value))
|
||||
return true;
|
||||
}
|
||||
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -343,7 +343,13 @@ namespace SabreTools.CommandLine.Inputs
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Investigate if nested features should be supported
|
||||
// Check all children recursively
|
||||
foreach (var child in Children.Values)
|
||||
{
|
||||
if (child.TryGetFeature(key, out value))
|
||||
return true;
|
||||
}
|
||||
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user