@@ -22,7 +22,7 @@ public class HelpProvider : IHelpProvider
2222 protected virtual bool ShowOptionDefaultValues { get ; }
2323
2424 /// <summary>
25- /// Gets a value indicating whether a trailing period of a command description is trimmed in the help text.
25+ /// Gets a value indicating whether a trailing period of a description is trimmed in the help text.
2626 /// </summary>
2727 protected virtual bool TrimTrailingPeriod { get ; }
2828
@@ -171,7 +171,7 @@ public virtual IEnumerable<IRenderable> GetDescription(ICommandModel model, ICom
171171
172172 var composer = NewComposer ( ) ;
173173 composer . Style ( helpStyles ? . Description ? . Header ?? Style . Plain , $ "{ resources . Description } :") . LineBreak ( ) ;
174- composer . Text ( command . Description ) . LineBreak ( ) ;
174+ composer . Text ( NormalizeDescription ( command . Description ) ) . LineBreak ( ) ;
175175 yield return composer . LineBreak ( ) ;
176176 }
177177
@@ -364,14 +364,14 @@ public virtual IEnumerable<IRenderable> GetArguments(ICommandModel model, IComma
364364 {
365365 grid . AddRow (
366366 NewComposer ( ) . Style ( helpStyles ? . Arguments ? . RequiredArgument ?? Style . Plain , $ "<{ argument . Name } >") ,
367- NewComposer ( ) . Text ( argument . Description ? . TrimEnd ( '.' ) ?? " " ) ) ;
367+ NewComposer ( ) . Text ( NormalizeDescription ( argument . Description ) ) ) ;
368368 }
369369
370370 foreach ( var argument in arguments . Where ( x => ! x . Required ) . OrderBy ( x => x . Position ) )
371371 {
372372 grid . AddRow (
373373 NewComposer ( ) . Style ( helpStyles ? . Arguments ? . OptionalArgument ?? Style . Plain , $ "[{ argument . Name } ]") ,
374- NewComposer ( ) . Text ( argument . Description ? . TrimEnd ( '.' ) ?? " " ) ) ;
374+ NewComposer ( ) . Text ( NormalizeDescription ( argument . Description ) ) ) ;
375375 }
376376
377377 result . Add ( grid ) ;
@@ -428,7 +428,7 @@ public virtual IEnumerable<IRenderable> GetOptions(ICommandModel model, ICommand
428428 columns . Add ( GetDefaultValueForOption ( option . DefaultValue ) ) ;
429429 }
430430
431- columns . Add ( NewComposer ( ) . Text ( option . Description ? . TrimEnd ( '.' ) ?? " " ) ) ;
431+ columns . Add ( NewComposer ( ) . Text ( NormalizeDescription ( option . Description ) ) ) ;
432432
433433 grid . AddRow ( columns . ToArray ( ) ) ;
434434 }
@@ -478,18 +478,9 @@ public virtual IEnumerable<IRenderable> GetCommands(ICommandModel model, IComman
478478 arguments . Space ( ) ;
479479 }
480480
481- if ( TrimTrailingPeriod )
482- {
483- grid . AddRow (
484- NewComposer ( ) . Text ( arguments . ToString ( ) . TrimEnd ( ) ) ,
485- NewComposer ( ) . Text ( child . Description ? . TrimEnd ( '.' ) ?? " " ) ) ;
486- }
487- else
488- {
489- grid . AddRow (
490- NewComposer ( ) . Text ( arguments . ToString ( ) . TrimEnd ( ) ) ,
491- NewComposer ( ) . Text ( child . Description ?? " " ) ) ;
492- }
481+ grid . AddRow (
482+ NewComposer ( ) . Text ( arguments . ToString ( ) . TrimEnd ( ) ) ,
483+ NewComposer ( ) . Text ( NormalizeDescription ( child . Description ) ) ) ;
493484 }
494485
495486 result . Add ( grid ) ;
@@ -566,4 +557,16 @@ private Composer GetDefaultValueForOption(object? defaultValue)
566557 _ => NewComposer ( ) . Style ( helpStyles ? . Options ? . DefaultValue ?? Style . Plain , defaultValue ? . ToString ( ) ?? string . Empty ) ,
567558 } ;
568559 }
560+
561+ private string NormalizeDescription ( string ? description )
562+ {
563+ if ( description == null )
564+ {
565+ return " " ;
566+ }
567+
568+ return TrimTrailingPeriod
569+ ? description . TrimEnd ( '.' )
570+ : description ;
571+ }
569572}
0 commit comments