diff --git a/SabreTools.CommandLine.Test/CommandSetTests.cs b/SabreTools.CommandLine.Test/CommandSetTests.cs
index c2c830c..3c48404 100644
--- a/SabreTools.CommandLine.Test/CommandSetTests.cs
+++ b/SabreTools.CommandLine.Test/CommandSetTests.cs
@@ -13,9 +13,16 @@ namespace SabreTools.CommandLine.Test
var input1 = new FlagInput("input1", "--input1", "input1");
var input2 = new FlagInput("input2", "--input2", "input2");
+ var feature1 = new MockFeature("feature1", "feature1", "feature1");
+ var inputA = new FlagInput("inputA", "--inputA", "inputA");
+ var inputB = new FlagInput("inputB", "--inputB", "inputB");
+ feature1.Add(inputA);
+ feature1.Add(inputB);
+
var featureSet = new CommandSet();
featureSet.Add(input1);
featureSet.Add(input2);
+ featureSet.AddChildrenFrom(feature1);
var actualInput1 = featureSet["input1"];
Assert.NotNull(actualInput1);
@@ -27,6 +34,14 @@ namespace SabreTools.CommandLine.Test
var actualInput3 = featureSet["input3"];
Assert.Null(actualInput3);
+
+ var actualInputA = featureSet["inputA"];
+ Assert.NotNull(actualInputA);
+ Assert.Equal("inputA", actualInputA.Name);
+
+ var actualinputB = featureSet["inputB"];
+ Assert.NotNull(actualinputB);
+ Assert.Equal("inputB", actualinputB.Name);
}
[Fact]
diff --git a/SabreTools.CommandLine/CommandSet.cs b/SabreTools.CommandLine/CommandSet.cs
index 7932216..e2d2ffd 100644
--- a/SabreTools.CommandLine/CommandSet.cs
+++ b/SabreTools.CommandLine/CommandSet.cs
@@ -120,6 +120,29 @@ namespace SabreTools.CommandLine
public void Add(UserInput input)
=> _inputs.Add(input.Name, input);
+ ///
+ /// Add all children from an input to the set
+ ///
+ /// UserInput object to retrieve children from
+ ///
+ /// This should only be used in situations where an input is defined
+ /// but not used within the context of the command set directly.
+ ///
+ /// This is helpful for when there are applications with default functionality
+ /// that need to be able to expose both defined features as well as
+ /// the default functionality in help text.
+ ///
+ /// If there is any overlap between existing names and the names from
+ /// any of the children, this operation will overwrite them.
+ ///
+ public void AddChildrenFrom(UserInput input)
+ {
+ foreach (var kvp in input.Children)
+ {
+ _inputs.Add(kvp.Key, kvp.Value);
+ }
+ }
+
#endregion
#region Children
diff --git a/SabreTools.CommandLine/Inputs/UserInput.cs b/SabreTools.CommandLine/Inputs/UserInput.cs
index 07dbe70..aa9352b 100644
--- a/SabreTools.CommandLine/Inputs/UserInput.cs
+++ b/SabreTools.CommandLine/Inputs/UserInput.cs
@@ -41,7 +41,7 @@ namespace SabreTools.CommandLine.Inputs
///
/// Set of children associated with this input
///
- protected readonly Dictionary Children = [];
+ internal protected readonly Dictionary Children = [];
#endregion