@@ -31,6 +31,8 @@ public class HelpText
3131 private StringBuilder optionsHelp ;
3232 private bool addDashesToOption ;
3333 private bool addEnumValuesToHelpText ;
34+ private bool autoHelp ;
35+ private bool autoVersion ;
3436
3537 /// <summary>
3638 /// Initializes a new instance of the <see cref="CommandLine.Text.HelpText"/> class.
@@ -113,6 +115,8 @@ public HelpText(SentenceBuilder sentenceBuilder, string heading, string copyrigh
113115 this . sentenceBuilder = sentenceBuilder ;
114116 this . heading = heading ;
115117 this . copyright = copyright ;
118+ this . autoHelp = true ;
119+ this . autoVersion = true ;
116120 }
117121
118122 /// <summary>
@@ -183,6 +187,24 @@ public bool AddEnumValuesToHelpText
183187 set { addEnumValuesToHelpText = value ; }
184188 }
185189
190+ /// <summary>
191+ /// Gets or sets a value indicating whether implicit option or verb 'help' should be supported.
192+ /// </summary>
193+ public bool AutoHelp
194+ {
195+ get { return autoHelp ; }
196+ set { autoHelp = value ; }
197+ }
198+
199+ /// <summary>
200+ /// Gets or sets a value indicating whether implicit option or verb 'version' should be supported.
201+ /// </summary>
202+ public bool AutoVersion
203+ {
204+ get { return autoVersion ; }
205+ set { autoVersion = value ; }
206+ }
207+
186208 /// <summary>
187209 /// Gets the <see cref="SentenceBuilder"/> instance specified in constructor.
188210 /// </summary>
@@ -676,8 +698,11 @@ private IEnumerable<Specification> GetSpecificationsFromType(Type type)
676698 {
677699 var specs = type . GetSpecifications ( Specification . FromProperty ) ;
678700 var optionSpecs = specs
679- . OfType < OptionSpecification > ( )
680- . Concat ( new [ ] { MakeHelpEntry ( ) , MakeVersionEntry ( ) } ) ;
701+ . OfType < OptionSpecification > ( ) ;
702+ if ( autoHelp )
703+ optionSpecs = optionSpecs . Concat ( new [ ] { MakeHelpEntry ( ) } ) ;
704+ if ( autoVersion )
705+ optionSpecs = optionSpecs . Concat ( new [ ] { MakeVersionEntry ( ) } ) ;
681706 var valueSpecs = specs
682707 . OfType < ValueSpecification > ( )
683708 . OrderBy ( v => v . Index ) ;
@@ -707,15 +732,20 @@ private static Maybe<Tuple<UsageAttribute, IEnumerable<Example>>> GetUsageFromTy
707732
708733 private IEnumerable < Specification > AdaptVerbsToSpecifications ( IEnumerable < Type > types )
709734 {
710- return ( from verbTuple in Verb . SelectFromTypes ( types )
735+ var optionSpecs = from verbTuple in Verb . SelectFromTypes ( types )
711736 select
712737 OptionSpecification . NewSwitch (
713738 string . Empty ,
714739 verbTuple . Item1 . Name ,
715740 false ,
716741 verbTuple . Item1 . HelpText ,
717742 string . Empty ,
718- verbTuple . Item1 . Hidden ) ) . Concat ( new [ ] { MakeHelpEntry ( ) , MakeVersionEntry ( ) } ) ;
743+ verbTuple . Item1 . Hidden ) ;
744+ if ( autoHelp )
745+ optionSpecs = optionSpecs . Concat ( new [ ] { MakeHelpEntry ( ) } ) ;
746+ if ( autoVersion )
747+ optionSpecs = optionSpecs . Concat ( new [ ] { MakeVersionEntry ( ) } ) ;
748+ return optionSpecs ;
719749 }
720750
721751 private HelpText AddOptionsImpl (
0 commit comments