File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -853,7 +853,7 @@ private IEnumerable<Specification> AdaptVerbsToSpecifications(IEnumerable<Type>
853853 string . Empty ,
854854 verbTuple . Item1 . Name ,
855855 false ,
856- verbTuple . Item1 . HelpText ,
856+ verbTuple . Item1 . IsDefault ? "(Default Verb) " + verbTuple . Item1 . HelpText : verbTuple . Item1 . HelpText , //Default verb
857857 string . Empty ,
858858 verbTuple . Item1 . Hidden ) ;
859859 if ( autoHelp )
Original file line number Diff line number Diff line change @@ -18,7 +18,20 @@ public class Add_Verb
1818 [ Value ( 0 ) ]
1919 public string FileName { get ; set ; }
2020 }
21+ [ Verb ( "add" , isDefault : true , HelpText = "Add file contents to the index." ) ]
22+ public class Add_Verb_As_Default
23+ {
24+ [ Option ( 'p' , "patch" , SetName = "mode-p" ,
25+ HelpText = "Interactively choose hunks of patch between the index and the work tree and add them to the index." ) ]
26+ public bool Patch { get ; set ; }
2127
28+ [ Option ( 'f' , "force" , SetName = "mode-f" ,
29+ HelpText = "Allow adding otherwise ignored files." ) ]
30+ public bool Force { get ; set ; }
31+
32+ [ Value ( 0 ) ]
33+ public string FileName { get ; set ; }
34+ }
2235 [ Verb ( "commit" , HelpText = "Record changes to the repository." ) ]
2336 public class Commit_Verb
2437 {
Original file line number Diff line number Diff line change @@ -370,7 +370,30 @@ public void Implicit_help_screen_in_verb_scenario()
370370 lines [ 8 ] . Should ( ) . BeEquivalentTo ( "version Display version information." ) ;
371371 // Teardown
372372 }
373+
374+ [ Fact ]
375+ public void Help_screen_in_default_verb_scenario ( )
376+ {
377+ // Fixture setup
378+ var help = new StringWriter ( ) ;
379+ var sut = new Parser ( config => config . HelpWriter = help ) ;
373380
381+ // Exercise system
382+ sut . ParseArguments < Add_Verb_As_Default , Commit_Verb , Clone_Verb > ( new string [ ] { "--help" } ) ;
383+ var result = help . ToString ( ) ;
384+
385+ // Verify outcome
386+ result . Length . Should ( ) . BeGreaterThan ( 0 ) ;
387+ var lines = result . ToNotEmptyLines ( ) . TrimStringArray ( ) ;
388+ lines [ 0 ] . Should ( ) . Be ( HeadingInfo . Default . ToString ( ) ) ;
389+ lines [ 1 ] . Should ( ) . Be ( CopyrightInfo . Default . ToString ( ) ) ;
390+ lines [ 2 ] . Should ( ) . BeEquivalentTo ( "add (Default Verb) Add file contents to the index." ) ;
391+ lines [ 3 ] . Should ( ) . BeEquivalentTo ( "commit Record changes to the repository." ) ;
392+ lines [ 4 ] . Should ( ) . BeEquivalentTo ( "clone Clone a repository into a new directory." ) ;
393+ lines [ 5 ] . Should ( ) . BeEquivalentTo ( "help Display more information on a specific command." ) ;
394+ lines [ 6 ] . Should ( ) . BeEquivalentTo ( "version Display version information." ) ;
395+
396+ }
374397 [ Fact ]
375398 public void Double_dash_help_dispalys_verbs_index_in_verbs_scenario ( )
376399 {
You can’t perform that action at this time.
0 commit comments