From 029cfe6dc6af40fe1277eb91dbfc604de7e3d725 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 7 Oct 2025 12:13:11 -0400 Subject: [PATCH] Add optional default feature to CommandSet --- SabreTools.CommandLine/CommandSet.cs | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/SabreTools.CommandLine/CommandSet.cs b/SabreTools.CommandLine/CommandSet.cs index 687c1f4..b70edb1 100644 --- a/SabreTools.CommandLine/CommandSet.cs +++ b/SabreTools.CommandLine/CommandSet.cs @@ -40,6 +40,20 @@ namespace SabreTools.CommandLine #endregion + #region Properties + + /// + /// Feature that represents the default functionality + /// for a command set + /// + /// + /// It is recommended to use this in applications that + /// do not need multiple distinct functional modes + /// + public Feature? DefaultFeature { get; set; } + + #endregion + #region Constructors /// @@ -762,6 +776,17 @@ namespace SabreTools.CommandLine output.AddRange(outputs); } + // If there is a default feature + if (DefaultFeature != null) + { + foreach (var input in DefaultFeature.Children) + { + var outputs = input.Value.Format(pre: 2, midpoint: 30, detailed); + if (outputs != null) + output.AddRange(outputs); + } + } + // Append the footer, if needed if (_footer.Count > 0) output.AddRange(_footer); @@ -792,6 +817,17 @@ namespace SabreTools.CommandLine output.AddRange(outputs); } + // If there is a default feature + if (DefaultFeature != null) + { + foreach (var input in DefaultFeature.Children) + { + var outputs = input.Value.Format(pre: 2, midpoint: 30, detailed); + if (outputs != null) + output.AddRange(outputs); + } + } + // Append the footer, if needed if (_footer.Count > 0) output.AddRange(_footer);