Skip to content

Commit 7388936

Browse files
committed
ensure help is not shown when help option is not present
1 parent 45e5891 commit 7388936

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/System.CommandLine.Tests/ParseErrorReportingTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ public void When_there_are_parse_errors_then_customized_help_action_is_used_if_p
8686
wasCalled.Should().BeTrue();
8787
}
8888

89+
[Fact]
90+
public void When_no_help_option_is_present_then_help_is_not_shown_for_parse_errors()
91+
{
92+
CliRootCommand rootCommand = new();
93+
rootCommand.Options.Clear();
94+
var output = new StringWriter();
95+
CliConfiguration config = new(rootCommand)
96+
{
97+
Output = output
98+
};
99+
100+
config.Parse("oops").Invoke();
101+
102+
output.ToString().Should().NotShowHelp();
103+
}
104+
89105
private class SynchronousCustomHelpAction : SynchronousCliAction
90106
{
91107
private readonly Action _onInvoke;

0 commit comments

Comments
 (0)