@@ -16,8 +16,19 @@ namespace Microsoft.OpenApi.Hidi
16
16
static class Program
17
17
{
18
18
static async Task Main ( string [ ] args )
19
- {
20
- var rootCommand = new RootCommand ( ) { } ;
19
+ {
20
+ var rootCommand = CreateRootCommand ( ) ;
21
+
22
+ // Parse the incoming args and invoke the handler
23
+ await rootCommand . InvokeAsync ( args ) ;
24
+
25
+ //// Wait for logger to write messages to the console before exiting
26
+ await Task . Delay ( 10 ) ;
27
+ }
28
+
29
+ internal static RootCommand CreateRootCommand ( )
30
+ {
31
+ var rootCommand = new RootCommand ( ) { } ;
21
32
22
33
// command option parameters and aliases
23
34
var descriptionOption = new Option < string > ( "--openapi" , "Input OpenAPI description file path or URL" ) ;
@@ -46,7 +57,7 @@ static async Task Main(string[] args)
46
57
47
58
var settingsFileOption = new Option < string > ( "--settings-path" , "The configuration file with CSDL conversion settings." ) ;
48
59
settingsFileOption . AddAlias ( "--sp" ) ;
49
-
60
+
50
61
var logLevelOption = new Option < LogLevel > ( "--log-level" , ( ) => LogLevel . Information , "The log level to use when logging messages to the main output." ) ;
51
62
logLevelOption . AddAlias ( "--ll" ) ;
52
63
@@ -71,7 +82,7 @@ static async Task Main(string[] args)
71
82
logLevelOption
72
83
} ;
73
84
74
- validateCommand . Handler = new ValidateCommandHandler
85
+ validateCommand . Handler = new ValidateCommandHandler
75
86
{
76
87
DescriptionOption = descriptionOption ,
77
88
LogLevelOption = logLevelOption
@@ -88,7 +99,7 @@ static async Task Main(string[] args)
88
99
formatOption ,
89
100
terseOutputOption ,
90
101
settingsFileOption ,
91
- logLevelOption ,
102
+ logLevelOption ,
92
103
filterByOperationIdsOption ,
93
104
filterByTagsOption ,
94
105
filterByCollectionOption ,
@@ -123,7 +134,7 @@ static async Task Main(string[] args)
123
134
cleanOutputOption
124
135
} ;
125
136
126
- showCommand . Handler = new ShowCommandHandler
137
+ showCommand . Handler = new ShowCommandHandler
127
138
{
128
139
DescriptionOption = descriptionOption ,
129
140
OutputOption = outputOption ,
@@ -133,12 +144,7 @@ static async Task Main(string[] args)
133
144
rootCommand . Add ( showCommand ) ;
134
145
rootCommand . Add ( transformCommand ) ;
135
146
rootCommand . Add ( validateCommand ) ;
136
-
137
- // Parse the incoming args and invoke the handler
138
- await rootCommand . InvokeAsync ( args ) ;
139
-
140
- //// Wait for logger to write messages to the console before exiting
141
- await Task . Delay ( 10 ) ;
142
- }
147
+ return rootCommand ;
148
+ }
143
149
}
144
150
}
0 commit comments