From 5f463a4389b4e0dace68abb44d571b5c3905c148 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 5 Oct 2025 15:22:24 -0400 Subject: [PATCH] Rename TopLevelFlag to IsTopLevel and clean up wording --- SabreTools.CommandLine.Test/CommandSetTests.cs | 8 ++++---- SabreTools.CommandLine/CommandSet.cs | 16 +++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/SabreTools.CommandLine.Test/CommandSetTests.cs b/SabreTools.CommandLine.Test/CommandSetTests.cs index 7a71ee1..b1ee7ca 100644 --- a/SabreTools.CommandLine.Test/CommandSetTests.cs +++ b/SabreTools.CommandLine.Test/CommandSetTests.cs @@ -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); } } diff --git a/SabreTools.CommandLine/CommandSet.cs b/SabreTools.CommandLine/CommandSet.cs index e04528c..b5bc4d7 100644 --- a/SabreTools.CommandLine/CommandSet.cs +++ b/SabreTools.CommandLine/CommandSet.cs @@ -106,10 +106,12 @@ namespace SabreTools.CommandLine /// /// Get the input name for a given flag or short name /// - public string GetInputName(string name) + /// Name or flag value to match + /// User input name on success, empty string on error + 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 } /// - /// Check if a flag is a top-level (main application) flag + /// Check if a value is a direct child input /// - /// Name of the flag to check + /// Name or flag value to match /// True if the feature was found, false otherwise - 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!);