11using System ;
22using System . Collections . Generic ;
3+ using System . Diagnostics ;
34using System . Diagnostics . CodeAnalysis ;
45using System . Globalization ;
56using System . IO ;
@@ -45,25 +46,19 @@ public async Task<int> RunAsync(string[] args, CancellationToken cancellationTok
4546 {
4647 CliParseResult parseResult = CliArgumentsParser . Parse ( args ) ;
4748
48- if ( parseResult . ShowHelp )
49- {
50- await standardOutput . WriteLineAsync ( CliArgumentsParser . HelpText ) ;
51- return 0 ;
52- }
53-
54- if ( parseResult . Error is not null )
55- {
56- await standardError . WriteLineAsync ( parseResult . Error ) ;
57- await standardError . WriteLineAsync ( ) ;
58- await standardError . WriteLineAsync ( CliArgumentsParser . HelpText ) ;
59- return 1 ;
60- }
61-
6249 try
6350 {
64- switch ( parseResult . Command )
51+ switch ( parseResult )
6552 {
66- case ImportCommandOptions options :
53+ case CliParseResult . HelpResult :
54+ await standardOutput . WriteLineAsync ( CliArgumentsParser . HelpText ) ;
55+ return 0 ;
56+ case CliParseResult . FailureResult failure :
57+ await standardError . WriteLineAsync ( failure . Error ) ;
58+ await standardError . WriteLineAsync ( ) ;
59+ await standardError . WriteLineAsync ( CliArgumentsParser . HelpText ) ;
60+ return 1 ;
61+ case CliParseResult . ImportSuccessResult { Command : ImportCommandOptions options } :
6762 {
6863 Action < string > reporter = CreateReporter ( options . VerboseLogging ) ;
6964 PlateauImportService effectiveImportService = importServiceFactory . Create ( options , reporter ) ;
@@ -97,7 +92,7 @@ public async Task<int> RunAsync(string[] args, CancellationToken cancellationTok
9792
9893 return 0 ;
9994 }
100- case SearchCommandOptions options :
95+ case CliParseResult . SearchSuccessResult { Command : SearchCommandOptions options } :
10196 {
10297 DatasetSearchResult result = await datasetInspectionService . SearchAsync (
10398 options . CityGmlSourcePath ,
@@ -107,7 +102,7 @@ public async Task<int> RunAsync(string[] args, CancellationToken cancellationTok
107102 await WriteSearchResultAsync ( result , options . OutputFormat , cancellationToken ) ;
108103 return 0 ;
109104 }
110- case StatsCommandOptions options :
105+ case CliParseResult . StatsSuccessResult { Command : StatsCommandOptions options } :
111106 {
112107 DatasetStatsResult result = await datasetInspectionService . GetStatsAsync (
113108 options . CityGmlSourcePath ,
@@ -117,7 +112,7 @@ public async Task<int> RunAsync(string[] args, CancellationToken cancellationTok
117112 return 0 ;
118113 }
119114 default :
120- throw new InvalidOperationException ( "CLI parse succeeded without a supported command payload." ) ;
115+ throw new UnreachableException ( ) ;
121116 }
122117 }
123118 catch ( PlateauImportValidationException exception )
0 commit comments