Long description becomes detailed description

This commit is contained in:
Matt Nadareski
2025-10-05 18:03:47 -04:00
parent 480d66f88b
commit 1b88a9ed60
21 changed files with 98 additions and 98 deletions

View File

@@ -113,10 +113,10 @@ namespace SabreTools.CommandLine.Test
[InlineData("Some long description\n - With formatting", 3)]
[InlineData("Some long description\r\n - With formatting", 3)]
[InlineData("Some long description with multiple spaces", 2)]
public void FormatLongDescriptionTest(string longDescription, int expectedCount)
public void FormatDetailedDescriptionTest(string detailedDescription, int expectedCount)
{
var feature = new MockFeature("a", "a", "a", longDescription);
var formatted = feature.FormatLongDescription(pre: 0);
var feature = new MockFeature("a", "a", "a", detailedDescription);
var formatted = feature.FormatDetailedDescription(pre: 0);
Assert.Equal(expectedCount, formatted.Count);
}
@@ -125,13 +125,13 @@ namespace SabreTools.CommandLine.Test
/// </summary>
private class MockFeature : Feature
{
public MockFeature(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public MockFeature(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
}
public MockFeature(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public MockFeature(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
}

View File

@@ -671,13 +671,13 @@ namespace SabreTools.CommandLine.Test.Inputs
/// </summary>
private class MockUserInput : UserInput<object?>
{
public MockUserInput(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public MockUserInput(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
}
public MockUserInput(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public MockUserInput(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
}

View File

@@ -222,7 +222,7 @@ namespace SabreTools.CommandLine
/// Output a single feature recursively
/// </summary>
/// <param name="featureName">Name of the feature to output information for, if possible</param>
/// <param name="detailed">True if the long description should be formatted and output, false otherwise</param>
/// <param name="detailed">True if the detailed description should be formatted and output, false otherwise</param>
public void OutputFeatureHelp(string? featureName, bool detailed = false)
{
// If the feature name is null, empty, or just consisting of leading characters

View File

@@ -24,13 +24,13 @@ namespace SabreTools.CommandLine
#region Constructors
public Feature(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public Feature(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
}
public Feature(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public Feature(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
}

View File

@@ -11,16 +11,16 @@
private const string _description = "Show this help";
private const string _longDescription = "Built-in to most of the programs is a basic help text.";
private const string _detailedDescription = "Built-in to most of the programs is a basic help text.";
public Help()
: base(DisplayName, _defaultFlags, _description, _longDescription)
: base(DisplayName, _defaultFlags, _description, _detailedDescription)
{
RequiresInputs = false;
}
public Help(string[] flags)
: base(DisplayName, flags, _description, _longDescription)
: base(DisplayName, flags, _description, _detailedDescription)
{
RequiresInputs = false;
}

View File

@@ -11,16 +11,16 @@
private const string _description = "Show this detailed help";
private const string _longDescription = "Display a detailed help text to the screen.";
private const string _detailedDescription = "Display a detailed help text to the screen.";
public HelpExtended()
: base(DisplayName, _defaultFlags, _description, _longDescription)
: base(DisplayName, _defaultFlags, _description, _detailedDescription)
{
RequiresInputs = false;
}
public HelpExtended(string[] flags)
: base(DisplayName, flags, _description, _longDescription)
: base(DisplayName, flags, _description, _detailedDescription)
{
RequiresInputs = false;
}

View File

@@ -14,16 +14,16 @@ namespace SabreTools.CommandLine.Features
private const string _description = "Prints version";
private const string _longDescription = "Prints current program version.";
private const string _detailedDescription = "Prints current program version.";
public Version()
: base(DisplayName, _defaultFlags, _description, _longDescription)
: base(DisplayName, _defaultFlags, _description, _detailedDescription)
{
RequiresInputs = false;
}
public Version(string[] flags)
: base(DisplayName, flags, _description, _longDescription)
: base(DisplayName, flags, _description, _detailedDescription)
{
RequiresInputs = false;
}

View File

@@ -9,14 +9,14 @@ namespace SabreTools.CommandLine.Inputs
{
#region Constructors
public BooleanInput(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public BooleanInput(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
Value = null;
}
public BooleanInput(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public BooleanInput(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
Value = null;
}

View File

@@ -9,14 +9,14 @@ namespace SabreTools.CommandLine.Inputs
{
#region Constructors
public FlagInput(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public FlagInput(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
Value = false;
}
public FlagInput(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public FlagInput(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
Value = false;
}

View File

@@ -9,14 +9,14 @@ namespace SabreTools.CommandLine.Inputs
{
#region Constructors
public Int16Input(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public Int16Input(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
Value = null;
}
public Int16Input(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public Int16Input(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
Value = null;
}

View File

@@ -9,14 +9,14 @@ namespace SabreTools.CommandLine.Inputs
{
#region Constructors
public Int32Input(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public Int32Input(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
Value = null;
}
public Int32Input(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public Int32Input(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
Value = null;
}

View File

@@ -9,14 +9,14 @@ namespace SabreTools.CommandLine.Inputs
{
#region Constructors
public Int64Input(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public Int64Input(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
Value = null;
}
public Int64Input(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public Int64Input(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
Value = null;
}

View File

@@ -9,14 +9,14 @@ namespace SabreTools.CommandLine.Inputs
{
#region Constructors
public Int8Input(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public Int8Input(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
Value = null;
}
public Int8Input(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public Int8Input(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
Value = null;
}

View File

@@ -9,14 +9,14 @@ namespace SabreTools.CommandLine.Inputs
{
#region Constructors
public StringInput(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public StringInput(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
Value = null;
}
public StringInput(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public StringInput(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
Value = null;
}

View File

@@ -10,14 +10,14 @@ namespace SabreTools.CommandLine.Inputs
{
#region Constructors
public StringListInput(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public StringListInput(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
Value = null;
}
public StringListInput(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public StringListInput(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
Value = null;
}

View File

@@ -9,14 +9,14 @@ namespace SabreTools.CommandLine.Inputs
{
#region Constructors
public UInt16Input(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public UInt16Input(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
Value = null;
}
public UInt16Input(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public UInt16Input(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
Value = null;
}

View File

@@ -9,14 +9,14 @@ namespace SabreTools.CommandLine.Inputs
{
#region Constructors
public UInt32Input(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public UInt32Input(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
Value = null;
}
public UInt32Input(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public UInt32Input(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
Value = null;
}

View File

@@ -9,14 +9,14 @@ namespace SabreTools.CommandLine.Inputs
{
#region Constructors
public UInt64Input(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public UInt64Input(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
Value = null;
}
public UInt64Input(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public UInt64Input(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
Value = null;
}

View File

@@ -9,14 +9,14 @@ namespace SabreTools.CommandLine.Inputs
{
#region Constructors
public UInt8Input(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public UInt8Input(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
Value = null;
}
public UInt8Input(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public UInt8Input(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
Value = null;
}

View File

@@ -27,7 +27,7 @@ namespace SabreTools.CommandLine.Inputs
/// Optional detailed description of the input
/// </summary>
/// <remarks>Can include newlines and additional formatting</remarks>
private string? LongDescription { get; }
private string? DetailedDescription { get; }
#endregion
@@ -47,20 +47,20 @@ namespace SabreTools.CommandLine.Inputs
#region Constructors
public UserInput(string name, string flag, string description, string? longDescription = null)
public UserInput(string name, string flag, string description, string? detailedDescription = null)
{
Name = name;
Flags.Add(flag);
Description = description;
LongDescription = longDescription;
DetailedDescription = detailedDescription;
}
public UserInput(string name, string[] flags, string description, string? longDescription = null)
public UserInput(string name, string[] flags, string description, string? detailedDescription = null)
{
Name = name;
Flags.AddRange(flags);
Description = description;
LongDescription = longDescription;
DetailedDescription = detailedDescription;
}
#endregion
@@ -630,7 +630,7 @@ namespace SabreTools.CommandLine.Inputs
/// <summary>
/// Create formatted help text
/// </summary>
/// <param name="detailed">True if the long description should be formatted and output, false otherwise</param>
/// <param name="detailed">True if the detailed description should be formatted and output, false otherwise</param>
/// <returns>Help text formatted as a list of strings</returns>
public List<string> Format(bool detailed = false)
=> Format(pre: 0, midpoint: 0, detailed);
@@ -640,7 +640,7 @@ namespace SabreTools.CommandLine.Inputs
/// </summary>
/// <param name="pre">Positive number representing number of spaces to put in front of the feature</param>
/// <param name="midpoint">Positive number representing the column where the description should start</param>
/// <param name="detailed">True if the long description should be formatted and output, false otherwise</param>
/// <param name="detailed">True if the detailed description should be formatted and output, false otherwise</param>
/// <returns>Help text formatted as a list of strings</returns>
public List<string> Format(int pre, int midpoint, bool detailed = false)
{
@@ -650,9 +650,9 @@ namespace SabreTools.CommandLine.Inputs
// Add the standard line
outputList.Add(FormatStandard(pre, midpoint));
// Add the long description, if needed
// Add the detailed description, if needed
if (detailed)
outputList.AddRange(FormatLongDescription(pre + 4));
outputList.AddRange(FormatDetailedDescription(pre + 4));
return outputList;
}
@@ -660,7 +660,7 @@ namespace SabreTools.CommandLine.Inputs
/// <summary>
/// Create formatted help text including all children
/// </summary>
/// <param name="detailed">True if the long description should be formatted and output, false otherwise</param>
/// <param name="detailed">True if the detailed description should be formatted and output, false otherwise</param>
/// <returns>Help text formatted as a list of strings</returns>
public List<string> FormatRecursive(bool detailed = false)
=> FormatRecursive(tabLevel: 0, pre: 0, midpoint: 0, detailed);
@@ -670,7 +670,7 @@ namespace SabreTools.CommandLine.Inputs
/// </summary>
/// <param name="pre">Positive number representing number of spaces to put in front of the feature</param>
/// <param name="midpoint">Positive number representing the column where the description should start</param>
/// <param name="detailed">True if the long description should be formatted and output, false otherwise</param>
/// <param name="detailed">True if the detailed description should be formatted and output, false otherwise</param>
/// <returns>Help text formatted as a list of strings</returns>
public List<string> FormatRecursive(int pre, int midpoint, bool detailed = false)
=> FormatRecursive(tabLevel: 0, pre, midpoint, detailed);
@@ -713,19 +713,19 @@ namespace SabreTools.CommandLine.Inputs
}
/// <summary>
/// Format the long description help output lines
/// Format the detailed description help output lines
/// </summary>
/// <param name="pre">Positive number representing number of spaces to put in front of the lines</param>
/// <returns>Pre-split output lines</returns>
internal List<string> FormatLongDescription(int pre)
internal List<string> FormatDetailedDescription(int pre)
{
// If the long description is null or empty
if (string.IsNullOrEmpty(LongDescription))
// If the detailed description is null or empty
if (string.IsNullOrEmpty(DetailedDescription))
return [];
// Normalize the description for output
string longDescription = LongDescription!.Replace("\r\n", "\n");
longDescription = longDescription.Replace("\n", "\n ");
string detailedDescription = DetailedDescription!.Replace("\r\n", "\n");
detailedDescription = detailedDescription.Replace("\n", "\n ");
// Get the width of the console for wrapping reference
int width = (Console.WindowWidth == 0 ? 80 : Console.WindowWidth) - 1;
@@ -736,7 +736,7 @@ namespace SabreTools.CommandLine.Inputs
output.Append(CreatePadding(pre));
// Now split the input description and start processing
string[]? split = longDescription.Split(' ');
string[]? split = detailedDescription.Split(' ');
for (int i = 0; i < split.Length; i++)
{
// Cache the current segment
@@ -802,7 +802,7 @@ namespace SabreTools.CommandLine.Inputs
/// <param name="tabLevel">Level of indentation for this feature</param>
/// <param name="pre">Positive number representing number of spaces to put in front of the feature</param>
/// <param name="midpoint">Positive number representing the column where the description should start</param>
/// <param name="detailed">True if the long description should be formatted and output, false otherwise</param>
/// <param name="detailed">True if the detailed description should be formatted and output, false otherwise</param>
/// <returns>Help text formatted as a list of strings</returns>
private List<string> FormatRecursive(int tabLevel, int pre = 0, int midpoint = 0, bool detailed = false)
{
@@ -821,9 +821,9 @@ namespace SabreTools.CommandLine.Inputs
// Add the standard line
outputList.Add(FormatStandard(preAdjusted, midpointAdjusted));
// Add the long description, if needed
// Add the detailed description, if needed
if (detailed)
outputList.AddRange(FormatLongDescription(preAdjusted + 4));
outputList.AddRange(FormatDetailedDescription(preAdjusted + 4));
// Append all children recursively
foreach (var feature in Children.Values)

View File

@@ -12,13 +12,13 @@ namespace SabreTools.CommandLine.Inputs
#region Constructors
public UserInput(string name, string flag, string description, string? longDescription = null)
: base(name, flag, description, longDescription)
public UserInput(string name, string flag, string description, string? detailedDescription = null)
: base(name, flag, description, detailedDescription)
{
}
public UserInput(string name, string[] flags, string description, string? longDescription = null)
: base(name, flags, description, longDescription)
public UserInput(string name, string[] flags, string description, string? detailedDescription = null)
: base(name, flags, description, detailedDescription)
{
}