Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/CommandLineUtils/HelpText/DefaultHelpTextGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ protected virtual void GenerateUsage(
output.Write(stack.Pop());
}

if (visibleCommands.Any())
{
output.Write(" [command]");
}

if (visibleOptions.Any())
{
output.Write(" [options]");
Expand All @@ -157,11 +162,6 @@ protected virtual void GenerateUsage(
output.Write(">");
}

if (visibleCommands.Any())
{
output.Write(" [command]");
}

if (application.AllowArgumentSeparator)
{
output.Write(" [[--] <arg>...]");
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 @@ -800,7 +800,7 @@ public void HelpOptionIsInherited(string helpOptionString)
outData = outWriter.ToString();

Assert.True(helpOption.HasValue());
Assert.Contains("Usage: lvl1 [options]", outData);
Assert.Contains("Usage: lvl1 [command] [options]", outData);
}
}

Expand Down
6 changes: 3 additions & 3 deletions test/CommandLineUtils.Tests/HelpOptionAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ public void HelpOptionIsInherited()
[InlineData(new[] { "get", "--help" }, "Usage: updater get [options]")]
[InlineData(new[] { "get", "-h" }, "Usage: updater get [options]")]
[InlineData(new[] { "get", "-?" }, "Usage: updater get [options]")]
[InlineData(new[] { "--help" }, "Usage: updater [options] [command]")]
[InlineData(new[] { "-h" }, "Usage: updater [options] [command]")]
[InlineData(new[] { "-?" }, "Usage: updater [options] [command]")]
[InlineData(new[] { "--help" }, "Usage: updater [command] [options]")]
[InlineData(new[] { "-h" }, "Usage: updater [command] [options]")]
[InlineData(new[] { "-?" }, "Usage: updater [command] [options]")]
public void NestedHelpOptionsChoosesHelpOptionNearestSelectedCommand(string[] args, string helpNeedle)
{
var sb = new StringBuilder();
Expand Down
4 changes: 2 additions & 2 deletions test/CommandLineUtils.Tests/SubcommandAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void HandlesHelp_Middle()
};
var rc = CommandLineApplication.Execute<MasterApp>(console, "level1", "--help");
Assert.Equal(0, rc);
Assert.Contains("Usage: master level1 [options]", sb.ToString());
Assert.Contains("Usage: master level1 [command] [options]", sb.ToString());
}

[Fact]
Expand All @@ -154,7 +154,7 @@ public void HandlesHelp_Top()
};
var rc = CommandLineApplication.Execute<MasterApp>(console, "--help");
Assert.Equal(0, rc);
Assert.Contains("Usage: master [options]", sb.ToString());
Assert.Contains("Usage: master [command] [options]", sb.ToString());
}

[Fact]
Expand Down