|
29 | 29 | import jadx.api.args.ResourceNameSource; |
30 | 30 | import jadx.api.args.UserRenamesMappingsMode; |
31 | 31 | import jadx.core.deobf.conditions.DeobfWhitelist; |
32 | | -import jadx.core.utils.exceptions.JadxException; |
| 32 | +import jadx.core.utils.exceptions.JadxArgsValidateException; |
33 | 33 | import jadx.core.utils.files.FileUtils; |
34 | 34 |
|
35 | 35 | public class JadxCLIArgs { |
@@ -287,14 +287,13 @@ private boolean process(JCommanderWrapper<JadxCLIArgs> jcw) { |
287 | 287 | System.out.println(JadxDecompiler.getVersion()); |
288 | 288 | return false; |
289 | 289 | } |
290 | | - try { |
291 | | - if (threadsCount <= 0) { |
292 | | - throw new JadxException("Threads count must be positive, got: " + threadsCount); |
| 290 | + if (threadsCount <= 0) { |
| 291 | + throw new JadxArgsValidateException("Threads count must be positive, got: " + threadsCount); |
| 292 | + } |
| 293 | + for (String fileName : files) { |
| 294 | + if (fileName.startsWith("-")) { |
| 295 | + throw new JadxArgsValidateException("Unknown option: " + fileName); |
293 | 296 | } |
294 | | - } catch (JadxException e) { |
295 | | - System.err.println("ERROR: " + e.getMessage()); |
296 | | - jcw.printUsage(); |
297 | | - return false; |
298 | 297 | } |
299 | 298 | return true; |
300 | 299 | } |
@@ -559,8 +558,8 @@ public Set<RenameEnum> convert(String value) { |
559 | 558 | for (String s : value.split(",")) { |
560 | 559 | try { |
561 | 560 | set.add(RenameEnum.valueOf(s.trim().toUpperCase(Locale.ROOT))); |
562 | | - } catch (IllegalArgumentException e) { |
563 | | - throw new IllegalArgumentException( |
| 561 | + } catch (Exception e) { |
| 562 | + throw new JadxArgsValidateException( |
564 | 563 | '\'' + s + "' is unknown for parameter " + paramName |
565 | 564 | + ", possible values are " + enumValuesString(RenameEnum.values())); |
566 | 565 | } |
@@ -625,7 +624,7 @@ public E convert(String value) { |
625 | 624 | try { |
626 | 625 | return parse.apply(stringAsEnumName(value)); |
627 | 626 | } catch (Exception e) { |
628 | | - throw new IllegalArgumentException( |
| 627 | + throw new JadxArgsValidateException( |
629 | 628 | '\'' + value + "' is unknown, possible values are: " + enumValuesString(values.get())); |
630 | 629 | } |
631 | 630 | } |
|
0 commit comments