@@ -111,9 +111,9 @@ public void Synopsis_section_properly_wraps_description()
111
111
public void Command_name_in_synopsis_can_be_specified ( )
112
112
{
113
113
var command = new RootCommand
114
- {
115
- Name = "custom-name"
116
- } ;
114
+ {
115
+ Name = "custom-name"
116
+ } ;
117
117
118
118
var helpBuilder = GetHelpBuilder ( SmallMaxWidth ) ;
119
119
helpBuilder . Write ( command ) ;
@@ -138,10 +138,10 @@ public void Usage_section_shows_arguments_if_there_are_arguments_for_command_whe
138
138
string expectedDescriptor )
139
139
{
140
140
var argument = new Argument
141
- {
142
- Name = "the-args" ,
143
- Arity = new ArgumentArity ( minArity , maxArity )
144
- } ;
141
+ {
142
+ Name = "the-args" ,
143
+ Arity = new ArgumentArity ( minArity , maxArity )
144
+ } ;
145
145
var command = new Command ( "the-command" , "command help" )
146
146
{
147
147
argument ,
@@ -178,18 +178,18 @@ public void Usage_section_shows_arguments_if_there_are_arguments_for_command_whe
178
178
string expectedDescriptor )
179
179
{
180
180
var arg1 = new Argument
181
- {
182
- Name = "arg1" ,
183
- Arity = new ArgumentArity (
184
- minArityForArg1 ,
185
- maxArityForArg1 )
186
- } ;
181
+ {
182
+ Name = "arg1" ,
183
+ Arity = new ArgumentArity (
184
+ minArityForArg1 ,
185
+ maxArityForArg1 )
186
+ } ;
187
187
var arg2 = new Argument
188
- {
189
- Name = "arg2" ,
190
- Arity = new ArgumentArity (
191
- minArityForArg2 ,
192
- maxArityForArg2 )
188
+ {
189
+ Name = "arg2" ,
190
+ Arity = new ArgumentArity (
191
+ minArityForArg2 ,
192
+ maxArityForArg2 )
193
193
} ;
194
194
var command = new Command ( "the-command" , "command help" )
195
195
{
@@ -426,7 +426,7 @@ public void Usage_section_does_not_contain_hidden_argument()
426
426
var command = new Command ( commandName , "Does things" ) ;
427
427
var hiddenArg = new Argument < int >
428
428
{
429
- Name = "hidden" ,
429
+ Name = "hidden" ,
430
430
IsHidden = true
431
431
} ;
432
432
var visibleArg = new Argument < int >
@@ -442,7 +442,7 @@ public void Usage_section_does_not_contain_hidden_argument()
442
442
var expected =
443
443
$ "Usage:{ NewLine } " +
444
444
$ "{ _indentation } { commandName } <{ visibleArgName } >{ NewLine } { NewLine } ";
445
-
445
+
446
446
_console . Out . ToString ( ) . Should ( ) . Contain ( expected ) ;
447
447
}
448
448
@@ -465,7 +465,7 @@ public void Arguments_section_is_not_included_if_there_are_commands_but_no_argum
465
465
466
466
_helpBuilder . Write ( command ) ;
467
467
_console . Out . ToString ( ) . Should ( ) . NotContain ( "Arguments:" ) ;
468
-
468
+
469
469
_helpBuilder . Write ( command ) ;
470
470
_console . Out . ToString ( ) . Should ( ) . NotContain ( "Arguments:" ) ;
471
471
}
@@ -534,7 +534,7 @@ public void Arguments_section_includes_configured_argument_aliases()
534
534
Description = "Sets the verbosity."
535
535
}
536
536
} ;
537
-
537
+
538
538
_helpBuilder . Write ( command ) ;
539
539
540
540
var help = _console . Out . ToString ( ) ;
@@ -589,14 +589,14 @@ public void Arguments_section_does_not_contain_hidden_argument()
589
589
590
590
var expected =
591
591
$ "Arguments:{ NewLine } " +
592
- $ "{ _indentation } <{ visibleArgName } >{ _columnPadding } { visibleDesc } { NewLine } { NewLine } ";
592
+ $ "{ _indentation } <{ visibleArgName } >{ _columnPadding } { visibleDesc } { NewLine } { NewLine } ";
593
593
594
594
_helpBuilder . Write ( command ) ;
595
595
var help = _console . Out . ToString ( ) ;
596
596
597
597
help . Should ( ) . Contain ( expected ) ;
598
598
help . Should ( ) . NotContain ( hiddenArgName ) ;
599
- help . Should ( ) . NotContain ( hiddenDesc ) ;
599
+ help . Should ( ) . NotContain ( hiddenDesc ) ;
600
600
}
601
601
602
602
[ Fact ]
@@ -736,6 +736,34 @@ public void Arguments_section_properly_wraps_description()
736
736
_console . Out . ToString ( ) . Should ( ) . Contain ( expected ) ;
737
737
}
738
738
739
+ [ Fact ]
740
+ public void Arguments_section_properly_wraps ( )
741
+ {
742
+ var name = "argument-name-for-a-command-that-is-long-enough-to-wrap-to-a-new-line" ;
743
+ var description = "Argument description for a command with line breaks that is long enough to wrap to a new line." ;
744
+
745
+ var command = new RootCommand ( )
746
+ {
747
+ new Argument
748
+ {
749
+ Name = name ,
750
+ Description = description
751
+ }
752
+ } ;
753
+
754
+ HelpBuilder helpBuilder = GetHelpBuilder ( SmallMaxWidth ) ;
755
+ helpBuilder . Write ( command ) ;
756
+
757
+ var expected =
758
+ $ "Arguments:{ NewLine } " +
759
+ $ "{ _indentation } <argument-name-for-a-command-th{ _columnPadding } Argument description for a{ NewLine } " +
760
+ $ "{ _indentation } at-is-long-enough-to-wrap-to-a-{ _columnPadding } command with line breaks that{ NewLine } " +
761
+ $ "{ _indentation } new-line> { _columnPadding } is long enough to wrap to a new{ NewLine } " +
762
+ $ "{ _indentation } { _columnPadding } line.{ NewLine } { NewLine } ";
763
+
764
+ _console . Out . ToString ( ) . Should ( ) . Contain ( expected ) ;
765
+ }
766
+
739
767
[ Theory ]
740
768
[ InlineData ( typeof ( bool ) ) ]
741
769
[ InlineData ( typeof ( bool ? ) ) ]
@@ -813,10 +841,10 @@ public void Option_argument_descriptor_is_empty_for_boolean_values(Type type)
813
841
HelpBuilder helpBuilder = GetHelpBuilder ( SmallMaxWidth ) ;
814
842
815
843
helpBuilder . Write ( command ) ;
816
-
844
+
817
845
_console . Out . ToString ( ) . Should ( ) . Contain ( $ "--opt{ _columnPadding } { description } ") ;
818
846
}
819
-
847
+
820
848
[ Theory ]
821
849
[ InlineData ( typeof ( FileAccess ) ) ]
822
850
[ InlineData ( typeof ( FileAccess ? ) ) ]
@@ -947,7 +975,7 @@ public void Options_section_does_not_contain_option_with_HelpDefinition_that_IsH
947
975
{
948
976
IsHidden = false
949
977
} ) ;
950
-
978
+
951
979
952
980
_helpBuilder . Write ( command ) ;
953
981
@@ -1084,6 +1112,29 @@ public void Options_section_properly_wraps_description()
1084
1112
_console . Out . ToString ( ) . Should ( ) . Contain ( expected ) ;
1085
1113
}
1086
1114
1115
+ [ Fact ]
1116
+ public void Options_section_properly_wraps ( )
1117
+ {
1118
+ var alias = "--option-alias-for-a-command-that-is-long-enough-to-wrap-to-a-new-line" ;
1119
+ var description = "Option description that is long enough to wrap." ;
1120
+
1121
+ var command = new RootCommand ( )
1122
+ {
1123
+ new Option ( alias , description )
1124
+ } ;
1125
+
1126
+ HelpBuilder helpBuilder = GetHelpBuilder ( SmallMaxWidth ) ;
1127
+ helpBuilder . Write ( command ) ;
1128
+
1129
+ var expected =
1130
+ $ "Options:{ NewLine } " +
1131
+ $ "{ _indentation } --option-alias-for-a-command-th{ _columnPadding } Option description that is long{ NewLine } " +
1132
+ $ "{ _indentation } at-is-long-enough-to-wrap-to-a-{ _columnPadding } enough to wrap.{ NewLine } " +
1133
+ $ "{ _indentation } new-line{ NewLine } { NewLine } ";
1134
+
1135
+ _console . Out . ToString ( ) . Should ( ) . Contain ( expected ) ;
1136
+ }
1137
+
1087
1138
[ Fact ]
1088
1139
public void Options_section_does_not_contain_hidden_argument ( )
1089
1140
{
@@ -1126,13 +1177,13 @@ public void Required_options_are_indicated()
1126
1177
} ;
1127
1178
1128
1179
_helpBuilder . Write ( command ) ;
1129
-
1180
+
1130
1181
var help = _console . Out . ToString ( ) ;
1131
1182
1132
1183
help . Should ( )
1133
1184
. Contain ( "--required (REQUIRED)" ) ;
1134
1185
}
1135
-
1186
+
1136
1187
[ Fact ]
1137
1188
public void Required_options_are_indicated_when_argument_is_named ( )
1138
1189
{
@@ -1146,7 +1197,7 @@ public void Required_options_are_indicated_when_argument_is_named()
1146
1197
} ;
1147
1198
1148
1199
_helpBuilder . Write ( command ) ;
1149
-
1200
+
1150
1201
var help = _console . Out . ToString ( ) ;
1151
1202
1152
1203
help . Should ( )
@@ -1177,12 +1228,12 @@ public void Options_aliases_differing_only_by_prefix_are_deduplicated_favoring_d
1177
1228
} ;
1178
1229
1179
1230
_helpBuilder . Write ( command ) ;
1180
-
1231
+
1181
1232
var help = _console . Out . ToString ( ) ;
1182
1233
1183
1234
help . Should ( ) . NotContain ( "/x" ) ;
1184
1235
}
1185
-
1236
+
1186
1237
[ Fact ]
1187
1238
public void Options_aliases_differing_only_by_prefix_are_deduplicated_favoring_double_dashed_prefixes ( )
1188
1239
{
@@ -1192,7 +1243,7 @@ public void Options_aliases_differing_only_by_prefix_are_deduplicated_favoring_d
1192
1243
} ;
1193
1244
1194
1245
_helpBuilder . Write ( command ) ;
1195
-
1246
+
1196
1247
var help = _console . Out . ToString ( ) ;
1197
1248
1198
1249
help . Should ( ) . NotContain ( "/long" ) ;
@@ -1265,7 +1316,7 @@ public void Help_describes_default_value_for_option_with_argument_having_default
1265
1316
}
1266
1317
1267
1318
[ Fact ]
1268
- public void Help_should_not_contain_default_value_for_hidden_argument_defined_for_option ( )
1319
+ public void Help_should_not_contain_default_value_for_hidden_argument_defined_for_option ( )
1269
1320
{
1270
1321
var argument = new Argument
1271
1322
{
@@ -1427,7 +1478,7 @@ public void Subcommands_properly_wraps_description()
1427
1478
}
1428
1479
} ;
1429
1480
1430
- helpBuilder . Write ( command ) ;
1481
+ helpBuilder . Write ( command ) ;
1431
1482
1432
1483
var expected =
1433
1484
$ "Commands:{ NewLine } " +
@@ -1437,6 +1488,29 @@ public void Subcommands_properly_wraps_description()
1437
1488
_console . Out . ToString ( ) . Should ( ) . Contain ( expected ) ;
1438
1489
}
1439
1490
1491
+ [ Fact ]
1492
+ public void Subcommands_section_properly_wraps ( )
1493
+ {
1494
+ var name = "subcommand-name-that-is-long-enough-to-wrap-to-a-new-line" ;
1495
+ var description = "Subcommand description that is really long. So long that it caused the line to wrap." ;
1496
+
1497
+ var command = new RootCommand ( )
1498
+ {
1499
+ new Command ( name , description )
1500
+ } ;
1501
+
1502
+ var helpBuilder = GetHelpBuilder ( SmallMaxWidth ) ;
1503
+ helpBuilder . Write ( command ) ;
1504
+
1505
+ var expected =
1506
+ $ "Commands:{ NewLine } " +
1507
+ $ "{ _indentation } subcommand-name-that-is-long-en{ _columnPadding } Subcommand description that is{ NewLine } " +
1508
+ $ "{ _indentation } ough-to-wrap-to-a-new-line { _columnPadding } really long. So long that it{ NewLine } " +
1509
+ $ "{ _indentation } { _columnPadding } caused the line to wrap.{ NewLine } { NewLine } ";
1510
+
1511
+ _console . Out . ToString ( ) . Should ( ) . Contain ( expected ) ;
1512
+ }
1513
+
1440
1514
[ Fact ]
1441
1515
public void Subcommand_help_contains_command_with_empty_description ( )
1442
1516
{
@@ -1479,12 +1553,12 @@ public void Subcommand_help_does_not_contain_hidden_argument()
1479
1553
var subCommand = new Command ( "the-subcommand" ) ;
1480
1554
var hidden = new Argument < int > ( )
1481
1555
{
1482
- Name = "the-hidden" ,
1556
+ Name = "the-hidden" ,
1483
1557
IsHidden = true
1484
1558
} ;
1485
1559
var visible = new Argument < int > ( )
1486
1560
{
1487
- Name = "the-visible" ,
1561
+ Name = "the-visible" ,
1488
1562
IsHidden = false
1489
1563
} ;
1490
1564
subCommand . AddArgument ( hidden ) ;
@@ -1557,7 +1631,7 @@ public void Help_describes_default_value_for_subcommand_with_arguments_and_only_
1557
1631
}
1558
1632
1559
1633
[ Fact ]
1560
- public void Help_describes_default_values_for_subcommand_with_multiple_defaultable_arguments ( )
1634
+ public void Help_describes_default_values_for_subcommand_with_multiple_defaultable_arguments ( )
1561
1635
{
1562
1636
var argument = new Argument
1563
1637
{
0 commit comments