@@ -34,7 +34,7 @@ public async Task I_can_request_the_help_text_by_running_the_application_without
3434 }
3535
3636 [ Fact ]
37- public async Task I_can_request_the_help_text_by_running_the_application_with_the_help_option ( )
37+ public async Task I_can_request_the_help_text_by_running_the_application_with_the_implicit_help_option ( )
3838 {
3939 // Arrange
4040 var commandType = DynamicCommandBuilder . Compile (
@@ -65,7 +65,7 @@ public class DefaultCommand : ICommand
6565 }
6666
6767 [ Fact ]
68- public async Task I_can_request_the_help_text_by_running_the_application_with_the_help_option_even_if_the_default_command_is_not_defined ( )
68+ public async Task I_can_request_the_help_text_by_running_the_application_with_the_implicit_help_option_even_if_the_default_command_is_not_defined ( )
6969 {
7070 // Arrange
7171 var commandTypes = DynamicCommandBuilder . CompileMany (
@@ -102,7 +102,7 @@ public class NamedChildCommand : ICommand
102102 }
103103
104104 [ Fact ]
105- public async Task I_can_request_the_help_text_for_a_specific_command_by_running_the_application_and_specifying_its_name_with_the_help_option ( )
105+ public async Task I_can_request_the_help_text_for_a_specific_command_by_running_the_application_and_specifying_its_name_with_the_implicit_help_option ( )
106106 {
107107 // Arrange
108108 var commandTypes = DynamicCommandBuilder . CompileMany (
@@ -147,7 +147,7 @@ public class NamedChildCommand : ICommand
147147 }
148148
149149 [ Fact ]
150- public async Task I_can_request_the_help_text_for_a_specific_nested_command_by_running_the_application_and_specifying_its_name_with_the_help_option ( )
150+ public async Task I_can_request_the_help_text_for_a_specific_nested_command_by_running_the_application_and_specifying_its_name_with_the_implicit_help_option ( )
151151 {
152152 // Arrange
153153 var commandTypes = DynamicCommandBuilder . CompileMany (
@@ -476,7 +476,7 @@ public class Command : ICommand
476476 }
477477
478478 [ Fact ]
479- public async Task I_can_request_the_help_text_to_see_the_help_and_version_options ( )
479+ public async Task I_can_request_the_help_text_to_see_the_help_and_implicit_version_options ( )
480480 {
481481 // Arrange
482482 var commandType = DynamicCommandBuilder . Compile (
@@ -515,7 +515,7 @@ public class Command : ICommand
515515 }
516516
517517 [ Fact ]
518- public async Task I_can_request_the_help_text_on_a_named_command_to_see_the_help_option ( )
518+ public async Task I_can_request_the_help_text_on_a_named_command_to_see_the_implicit_help_option ( )
519519 {
520520 // Arrange
521521 var commandType = DynamicCommandBuilder . Compile (
@@ -974,7 +974,7 @@ public class SecondCommandSecondChildCommand : ICommand
974974 }
975975
976976 [ Fact ]
977- public async Task I_can_request_the_version_text_by_running_the_application_with_the_version_option ( )
977+ public async Task I_can_request_the_version_text_by_running_the_application_with_the_implicit_version_option ( )
978978 {
979979 // Arrange
980980 var application = new CliApplicationBuilder ( )
@@ -992,4 +992,72 @@ public async Task I_can_request_the_version_text_by_running_the_application_with
992992 var stdOut = FakeConsole . ReadOutputString ( ) ;
993993 stdOut . Trim ( ) . Should ( ) . Be ( "v6.9" ) ;
994994 }
995+
996+ [ Fact ]
997+ public async Task I_cannot_request_the_help_text_by_running_the_application_with_the_implicit_help_option_if_there_is_an_option_with_the_same_identifier ( )
998+ {
999+ // Arrange
1000+ var commandType = DynamicCommandBuilder . Compile (
1001+ // lang=csharp
1002+ """
1003+ [Command]
1004+ public class DefaultCommand : ICommand
1005+ {
1006+ [CommandOption("help", 'h')]
1007+ public string? Foo { get; init; }
1008+
1009+ public ValueTask ExecuteAsync(IConsole console) => default;
1010+ }
1011+ """
1012+ ) ;
1013+
1014+ var application = new CliApplicationBuilder ( )
1015+ . AddCommand ( commandType )
1016+ . UseConsole ( FakeConsole )
1017+ . SetDescription ( "This will be in help text" )
1018+ . Build ( ) ;
1019+
1020+ // Act
1021+ var exitCode = await application . RunAsync ( [ "--help" ] , new Dictionary < string , string > ( ) ) ;
1022+
1023+ // Assert
1024+ exitCode . Should ( ) . Be ( 0 ) ;
1025+
1026+ var stdOut = FakeConsole . ReadOutputString ( ) ;
1027+ stdOut . Should ( ) . NotContain ( "This will be in help text" ) ;
1028+ }
1029+
1030+ [ Fact ]
1031+ public async Task I_cannot_request_the_version_text_by_running_the_application_with_the_implicit_version_option_if_there_is_an_option_with_the_same_identifier ( )
1032+ {
1033+ // Arrange
1034+ var commandType = DynamicCommandBuilder . Compile (
1035+ // lang=csharp
1036+ """
1037+ [Command]
1038+ public class DefaultCommand : ICommand
1039+ {
1040+ [CommandOption("version")]
1041+ public string? Foo { get; init; }
1042+
1043+ public ValueTask ExecuteAsync(IConsole console) => default;
1044+ }
1045+ """
1046+ ) ;
1047+
1048+ var application = new CliApplicationBuilder ( )
1049+ . AddCommand ( commandType )
1050+ . SetVersion ( "v6.9" )
1051+ . UseConsole ( FakeConsole )
1052+ . Build ( ) ;
1053+
1054+ // Act
1055+ var exitCode = await application . RunAsync ( [ "--version" ] , new Dictionary < string , string > ( ) ) ;
1056+
1057+ // Assert
1058+ exitCode . Should ( ) . Be ( 0 ) ;
1059+
1060+ var stdOut = FakeConsole . ReadOutputString ( ) ;
1061+ stdOut . Trim ( ) . Should ( ) . NotBe ( "v6.9" ) ;
1062+ }
9951063}
0 commit comments