Skip to content

Commit

Permalink
Rearrange the order that commands are listed in the USAGE block and l…
Browse files Browse the repository at this point in the history
…ist all the commands on the line (#224)
  • Loading branch information
SteveBenz authored and natemcmaster committed Apr 9, 2019
1 parent 84e9baf commit daf989b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/CommandLineUtils/HelpText/DefaultHelpTextGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,16 @@ protected virtual void GenerateUsage(
output.Write(stack.Pop());
}

if (visibleArguments.Any())
if (visibleOptions.Any())
{
output.Write(" [arguments]");
output.Write(" [options]");
}

if (visibleOptions.Any())
foreach (var argument in visibleArguments)
{
output.Write(" [options]");
output.Write(" <");
output.Write(argument.Name);
output.Write(">");
}

if (visibleCommands.Any())
Expand Down
2 changes: 1 addition & 1 deletion test/CommandLineUtils.Tests/CommandLineApplicationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ public void HelpOptionIsInherited(string helpOptionString)
var outData = outWriter.ToString();

Assert.True(helpOption.HasValue());
Assert.Contains("Usage: lvl1 lvl2 [arguments] [options]", outData);
Assert.Contains("Usage: lvl1 lvl2 [options] <lvl-arg>", outData);

inputs = new[] { helpOptionString };
app.Execute(inputs);
Expand Down
2 changes: 1 addition & 1 deletion test/CommandLineUtils.Tests/HelpOptionAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void HelpOptionIsInherited()
var outData = sb.ToString();

Assert.True(app.OptionHelp.HasValue());
Assert.Contains("Usage: lvl1 lvl2 [arguments] [options]", outData);
Assert.Contains("Usage: lvl1 lvl2 [options] <lvl-arg>", outData);
}

[Theory]
Expand Down

0 comments on commit daf989b

Please sign in to comment.