From 01807285ed0da8a577b6c6314ff80b734f024d5d Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 20 Feb 2019 21:23:49 +0700 Subject: [PATCH] Refactor argument passing for mac app --- source/net/filebot/cli/ArgumentBean.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/source/net/filebot/cli/ArgumentBean.java b/source/net/filebot/cli/ArgumentBean.java index 6bbf3956..02b5c8b8 100644 --- a/source/net/filebot/cli/ArgumentBean.java +++ b/source/net/filebot/cli/ArgumentBean.java @@ -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; + } } }