44using System ;
55using System . Collections ;
66using System . Collections . Generic ;
7+ using System . ComponentModel . DataAnnotations ;
78using System . IO ;
89using System . Text ;
910using McMaster . Extensions . CommandLineUtils . HelpText ;
@@ -108,11 +109,11 @@ public void ShowHelp()
108109 var app = new CommandLineApplication ( ) ;
109110 app . HelpOption ( ) ;
110111 app . Option ( "--strOpt <E>" , "str option desc." , CommandOptionType . SingleValue ) ;
111- app . Option ( "--rStrOpt <E>" , "restricted str option desc." , CommandOptionType . SingleValue , o => o . Accepts ( ) . Values ( "Foo" , "Bar" ) ) ;
112+ app . Option ( "--rStrOpt <E>" , "restricted str option desc." , CommandOptionType . SingleValue , o => o . IsRequired ( ) . Accepts ( ) . Values ( "Foo" , "Bar" ) ) ;
112113 app . Option < int > ( "--intOpt <E>" , "int option desc." , CommandOptionType . SingleValue ) ;
113114 app . Option < SomeEnum > ( "--enumOpt <E>" , "enum option desc." , CommandOptionType . SingleValue ) ;
114115 app . Argument ( "SomeStringArgument" , "string arg desc." ) ;
115- app . Argument ( "RestrictedStringArgument" , "restricted string arg desc." , a=> a . Accepts ( ) . Values ( "Foo" , "Bar" ) ) ;
116+ app . Argument ( "RestrictedStringArgument" , "restricted string arg desc." , a => a . IsRequired ( ) . Accepts ( ) . Values ( "Foo" , "Bar" ) ) ;
116117 app . Argument < SomeEnum > ( "SomeEnumArgument" , "enum arg desc." ) ;
117118 var helpText = GetHelpText ( app ) ;
118119
@@ -176,6 +177,7 @@ public class MyApp
176177 public string strOpt { get ; set ; }
177178
178179 [ Option ( ShortName = "rStrOpt" , Description = "restricted str option desc." ) ]
180+ [ Required ]
179181 [ AllowedValues ( "Foo" , "Bar" ) ]
180182 public string rStrOpt { get ; set ; }
181183
@@ -189,6 +191,7 @@ public class MyApp
189191 public string SomeStringArgument { get ; set ; }
190192
191193 [ Argument ( 1 , Description = "restricted string arg desc." ) ]
194+ [ Required ]
192195 [ AllowedValues ( "Foo" , "Bar" ) ]
193196 public string RestrictedStringArgument { get ; set ; }
194197
0 commit comments