3
3
4
4
using System . CommandLine . Subsystems . Annotations ;
5
5
using System . CommandLine . Subsystems ;
6
+ using static System . Runtime . InteropServices . JavaScript . JSType ;
6
7
7
8
namespace System . CommandLine ;
8
9
@@ -18,31 +19,30 @@ namespace System.CommandLine;
18
19
public class HelpSubsystem ( IAnnotationProvider ? annotationProvider = null )
19
20
: CliSubsystem ( HelpAnnotations . Prefix , SubsystemKind . Help , annotationProvider )
20
21
{
21
- public void SetDescription ( CliSymbol symbol , string description )
22
- => SetAnnotation ( symbol , HelpAnnotations . Description , description ) ;
22
+ public CliOption < bool > HelpOption { get ; } = new CliOption < bool > ( "--help" , [ "-h" ] )
23
+ {
24
+ // TODO: Why don't we accept bool like any other bool option?
25
+ Arity = ArgumentArity . Zero
26
+ } ;
23
27
28
+ public void SetDescription ( CliSymbol symbol , string description )
29
+ => SetAnnotation ( symbol , HelpAnnotations . Description , description ) ;
24
30
public string GetDescription ( CliSymbol symbol )
25
31
=> TryGetAnnotation < string > ( symbol , HelpAnnotations . Description , out var value )
26
32
? value
27
33
: "" ;
28
-
29
34
public AnnotationAccessor < string > Description
30
35
=> new ( this , HelpAnnotations . Description ) ;
31
36
32
37
protected internal override CliConfiguration Initialize ( InitializationContext context )
33
38
{
34
- var option = new CliOption < bool > ( "--help" , [ "-h" ] )
35
- {
36
- // TODO: Why don't we accept bool like any other bool option?
37
- Arity = ArgumentArity . Zero
38
- } ;
39
- context . Configuration . RootCommand . Add ( option ) ;
39
+ context . Configuration . RootCommand . Add ( HelpOption ) ;
40
40
41
41
return context . Configuration ;
42
42
}
43
43
44
44
protected internal override bool GetIsActivated ( ParseResult ? parseResult )
45
- => parseResult is not null && parseResult . GetValue < bool > ( "--help" ) ;
45
+ => parseResult is not null && parseResult . GetValue ( HelpOption ) ;
46
46
47
47
protected internal override CliExit Execute ( PipelineContext pipelineContext )
48
48
{
0 commit comments