Skip to content

Commit 029cfe6

Browse files
committed
Add optional default feature to CommandSet
1 parent f38b873 commit 029cfe6

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

SabreTools.CommandLine/CommandSet.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ public class CommandSet
4040

4141
#endregion
4242

43+
#region Properties
44+
45+
/// <summary>
46+
/// Feature that represents the default functionality
47+
/// for a command set
48+
/// </summary>
49+
/// <remarks>
50+
/// It is recommended to use this in applications that
51+
/// do not need multiple distinct functional modes
52+
/// </remarks>
53+
public Feature? DefaultFeature { get; set; }
54+
55+
#endregion
56+
4357
#region Constructors
4458

4559
/// <summary>
@@ -762,6 +776,17 @@ public void OutputGenericHelp(bool detailed = false)
762776
output.AddRange(outputs);
763777
}
764778

779+
// If there is a default feature
780+
if (DefaultFeature != null)
781+
{
782+
foreach (var input in DefaultFeature.Children)
783+
{
784+
var outputs = input.Value.Format(pre: 2, midpoint: 30, detailed);
785+
if (outputs != null)
786+
output.AddRange(outputs);
787+
}
788+
}
789+
765790
// Append the footer, if needed
766791
if (_footer.Count > 0)
767792
output.AddRange(_footer);
@@ -792,6 +817,17 @@ public void OutputAllHelp(bool detailed = false)
792817
output.AddRange(outputs);
793818
}
794819

820+
// If there is a default feature
821+
if (DefaultFeature != null)
822+
{
823+
foreach (var input in DefaultFeature.Children)
824+
{
825+
var outputs = input.Value.Format(pre: 2, midpoint: 30, detailed);
826+
if (outputs != null)
827+
output.AddRange(outputs);
828+
}
829+
}
830+
795831
// Append the footer, if needed
796832
if (_footer.Count > 0)
797833
output.AddRange(_footer);

0 commit comments

Comments
 (0)