Refactor argument passing for mac app

This commit is contained in:
Reinhard Pointner 2019-02-20 21:23:49 +07:00
parent 0892aed310
commit 01807285ed
1 changed files with 11 additions and 2 deletions

View File

@ -394,8 +394,17 @@ public class ArgumentBean {
}
public static ArgumentBean parse(String... args) throws CmdLineException {
// MAS does not support or allow command-line applications and may run executables with strange arguments for no apparent reason (e.g. filebot.launcher -psn_0_774333) so we ignore arguments completely in this case
return Boolean.parseBoolean(System.getProperty("apple.app.launcher")) || args == null ? new ArgumentBean() : new ArgumentBean(args);
try {
return new ArgumentBean(args);
} catch (CmdLineException e) {
// MAS does not support or allow command-line applications and may run executables with strange arguments for no apparent reason (e.g. filebot.launcher -psn_0_774333) so we ignore arguments completely in this case
if (Boolean.parseBoolean(System.getProperty("apple.app.launcher"))) {
return new ArgumentBean();
}
// just throw exception as usual when called from command-line and display argument errors
throw e;
}
}
}