1515 */
1616package com .redhat .exhort .cli ;
1717
18- import static com .redhat .exhort .cli .AppUtils .exitWithError ;
19- import static com .redhat .exhort .cli .AppUtils .printException ;
20- import static com .redhat .exhort .cli .AppUtils .printLine ;
18+ import java .io .IOException ;
19+ import java .nio .file .Files ;
20+ import java .nio .file .Path ;
21+ import java .nio .file .Paths ;
22+ import java .util .concurrent .CompletableFuture ;
23+ import java .util .concurrent .ExecutionException ;
2124
2225import com .fasterxml .jackson .annotation .JsonInclude ;
2326import com .fasterxml .jackson .core .JsonProcessingException ;
2629import com .redhat .exhort .api .v4 .AnalysisReport ;
2730import com .redhat .exhort .api .v4 .ProviderReport ;
2831import com .redhat .exhort .api .v4 .Source ;
32+ import static com .redhat .exhort .cli .AppUtils .exitWithError ;
33+ import static com .redhat .exhort .cli .AppUtils .printException ;
34+ import static com .redhat .exhort .cli .AppUtils .printLine ;
2935import com .redhat .exhort .impl .ExhortApi ;
30- import java .io .IOException ;
31- import java .nio .file .Files ;
32- import java .nio .file .Path ;
33- import java .nio .file .Paths ;
34- import java .util .concurrent .CompletableFuture ;
35- import java .util .concurrent .ExecutionException ;
3636
3737public class App {
3838
@@ -81,7 +81,10 @@ private static CliArgs parseArgs(String[] args) {
8181
8282 Path path = validateFile (args [1 ]);
8383
84- OutputFormat outputFormat = parseOutputFormat (command , args [2 ]);
84+ OutputFormat outputFormat = OutputFormat .JSON ;
85+ if (args .length == 3 ) {
86+ outputFormat = parseOutputFormat (command , args [2 ]);
87+ }
8588
8689 return new CliArgs (command , path , outputFormat );
8790 }
@@ -99,10 +102,6 @@ private static Command parseCommand(String commandStr) {
99102 }
100103
101104 private static OutputFormat parseOutputFormat (Command command , String formatArg ) {
102- if (formatArg == null ) {
103- return OutputFormat .JSON ;
104- }
105-
106105 switch (formatArg ) {
107106 case "--summary" :
108107 return OutputFormat .SUMMARY ;
@@ -125,9 +124,6 @@ private static Path validateFile(String filePath) {
125124 if (!Files .isRegularFile (path )) {
126125 throw new IllegalArgumentException ("File is not a regular file: " + filePath );
127126 }
128- if (!Files .isReadable (path )) {
129- throw new IllegalArgumentException ("File is not readable: " + filePath );
130- }
131127 return path ;
132128 }
133129
0 commit comments