Skip to content

Commit

Permalink
Reduced padding length & changed short name long name order in template
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal Fazlani committed Jan 3, 2018
1 parent 66514bb commit e435ebb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CommandDotNet.Tests/CommandInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void CanIdentifyCommandInfoWithDescriptionAndName()
DefaultValue = DBNull.Value,
Type = typeof(int),
//Required = true,
EffectiveDescription = "Int32 some parameter description",
EffectiveDescription = "Int32".PadRight(Constants.PadLength)+"some parameter description",
TypeDisplayName = "Int32",
AnnotatedDescription = "some parameter description",
Details = "Int32",
Expand Down
2 changes: 1 addition & 1 deletion CommandDotNet.Tests/CommandParameterInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public CommandParameterInfoTests(ITestOutputHelper testOutputHelper) : base(test
new object[]
{
"id", CommandOptionType.SingleValue, DBNull.Value, "Int64", "Int64", "Id of person",
"Int64".PadRight(Constants.PadLength)+"Id of person", "--id | -i", typeof(long), true
"Int64".PadRight(Constants.PadLength)+"Id of person", "-i | --id", typeof(long), true
},
new object[]
{
Expand Down
2 changes: 1 addition & 1 deletion CommandDotNet/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public static class Constants
{
public const string HelpTemplate = "-h | -? | --help";

public const int PadLength = 50;
public const int PadLength = 30;
}
}
22 changes: 11 additions & 11 deletions CommandDotNet/Models/CommandOptionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,25 @@ private BooleanMode GetBooleanMode()
private string GetTemplate()
{
StringBuilder sb = new StringBuilder();

bool longNameAdded = false;

bool shortNameAdded = false;

if (!string.IsNullOrWhiteSpace(LongName))
bool longNameAdded = false;

if (!string.IsNullOrWhiteSpace(ShortName))
{
sb.Append($"--{LongName}");
longNameAdded = true;
sb.Append($"-{ShortName}");
shortNameAdded = true;
}

if (!string.IsNullOrWhiteSpace(ShortName))
if (!string.IsNullOrWhiteSpace(LongName))
{
if (longNameAdded)
if (shortNameAdded)
{
sb.Append(" | ");
}

sb.Append($"-{ShortName}");
shortNameAdded = true;
sb.Append($"--{LongName}");
longNameAdded = true;
}

if (!longNameAdded & !shortNameAdded)
Expand Down

0 comments on commit e435ebb

Please sign in to comment.