File tree Expand file tree Collapse file tree 6 files changed +28
-30
lines changed Expand file tree Collapse file tree 6 files changed +28
-30
lines changed Original file line number Diff line number Diff line change @@ -423,8 +423,7 @@ public void When_argument_cannot_be_parsed_as_the_specified_type_then_getting_va
423
423
argumentResult . ErrorMessage = $ "'{ argumentResult . Tokens . Single ( ) . Value } ' is not an integer";
424
424
425
425
return default ;
426
- } ) ,
427
- Description = ""
426
+ } )
428
427
}
429
428
} ;
430
429
Original file line number Diff line number Diff line change @@ -187,18 +187,16 @@ public void Usage_section_shows_arguments_if_there_are_arguments_for_command_whe
187
187
{
188
188
Name = "arg2" ,
189
189
Arity = new ArgumentArity (
190
- minArityForArg2 ,
190
+ minArityForArg2 ,
191
191
maxArityForArg2 )
192
- } ;
192
+ } ;
193
193
var command = new Command ( "the-command" , "command help" )
194
194
{
195
195
arg1 ,
196
196
arg2 ,
197
- new Option ( new [ ] { "-v" , "--verbosity" } )
198
- {
199
- Description = "Sets the verbosity"
200
- }
197
+ new Option ( new [ ] { "-v" , "--verbosity" } , "Sets the verbosity" )
201
198
} ;
199
+
202
200
var rootCommand = new RootCommand ( ) ;
203
201
rootCommand . AddCommand ( command ) ;
204
202
@@ -479,8 +477,7 @@ public void Arguments_section_is_included_if_there_are_commands_with_arguments_c
479
477
new Argument
480
478
{
481
479
Name = "arg command name" ,
482
- Description = "test" ,
483
- Arity = ArgumentArity . ExactlyOne
480
+ Description = "test"
484
481
}
485
482
} ;
486
483
Original file line number Diff line number Diff line change @@ -78,15 +78,15 @@ public void Parse_diagram_identifies_options_where_default_values_have_been_appl
78
78
{
79
79
new Option ( new [ ] { "-h" , "--height" } )
80
80
{
81
- Argument = new Argument < int > ( getDefaultValue : ( ) => 10 ) , Description = ""
81
+ Argument = new Argument < int > ( getDefaultValue : ( ) => 10 )
82
82
} ,
83
83
new Option ( new [ ] { "-w" , "--width" } )
84
84
{
85
- Argument = new Argument < int > ( getDefaultValue : ( ) => 15 ) , Description = ""
85
+ Argument = new Argument < int > ( getDefaultValue : ( ) => 15 )
86
86
} ,
87
87
new Option ( new [ ] { "-c" , "--color" } )
88
88
{
89
- Argument = new Argument < ConsoleColor > ( ( ) => ConsoleColor . Cyan ) , Description = ""
89
+ Argument = new Argument < ConsoleColor > ( ( ) => ConsoleColor . Cyan )
90
90
}
91
91
} ;
92
92
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public async Task Parse_directive_writes_parse_diagram()
29
29
rootCommand . AddCommand ( subcommand ) ;
30
30
var option = new Option ( new [ ] { "-c" , "--count" } )
31
31
{
32
- Argument = new Argument < int > ( ) , Description = ""
32
+ Argument = new Argument < int > ( )
33
33
} ;
34
34
subcommand . AddOption ( option ) ;
35
35
Original file line number Diff line number Diff line change @@ -7,24 +7,32 @@ namespace System.CommandLine
7
7
{
8
8
public class Argument < T > : Argument
9
9
{
10
- public Argument ( string name ) : this ( )
10
+ public Argument ( ) : base ( null )
11
11
{
12
- Name = name ;
12
+ ArgumentType = typeof ( T ) ;
13
13
}
14
14
15
- public Argument ( ) : base ( null )
15
+ public Argument (
16
+ string name ,
17
+ string description = null ) : base ( name )
16
18
{
17
19
ArgumentType = typeof ( T ) ;
20
+ Description = description ;
18
21
}
19
22
20
- public Argument ( string name , Func < T > getDefaultValue ) : this ( name )
23
+ public Argument (
24
+ string name ,
25
+ Func < T > getDefaultValue ,
26
+ string description = null ) : this ( name )
21
27
{
22
28
if ( getDefaultValue == null )
23
29
{
24
30
throw new ArgumentNullException ( nameof ( getDefaultValue ) ) ;
25
31
}
26
32
27
33
SetDefaultValueFactory ( ( ) => getDefaultValue ( ) ) ;
34
+
35
+ Description = description ;
28
36
}
29
37
30
38
public Argument ( Func < T > getDefaultValue ) : this ( )
Original file line number Diff line number Diff line change @@ -7,22 +7,16 @@ namespace System.CommandLine
7
7
{
8
8
public class Option < T > : Option
9
9
{
10
- public Option ( string alias ) : base ( alias )
11
- {
12
- Argument = new Argument < T > ( ) ;
13
- }
14
-
15
- public Option ( string [ ] aliases ) : base ( aliases )
16
- {
17
- Argument = new Argument < T > ( ) ;
18
- }
19
-
20
- public Option ( string alias , string description ) : base ( alias , description )
10
+ public Option (
11
+ string alias ,
12
+ string description = null ) : base ( alias , description )
21
13
{
22
14
Argument = new Argument < T > ( ) ;
23
15
}
24
16
25
- public Option ( string [ ] aliases , string description ) : base ( aliases , description )
17
+ public Option (
18
+ string [ ] aliases ,
19
+ string description = null ) : base ( aliases , description )
26
20
{
27
21
Argument = new Argument < T > ( ) ;
28
22
}
You can’t perform that action at this time.
0 commit comments