From d30456fec4750dbcf1af7a34d9f660f9b5f06780 Mon Sep 17 00:00:00 2001 From: issacto Date: Tue, 27 Jun 2023 17:38:27 +0800 Subject: [PATCH] fix arguments bug --- .../features/argumentHandler/ArgumentHandler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/openmainframeproject/cobolcheck/features/argumentHandler/ArgumentHandler.java b/src/main/java/org/openmainframeproject/cobolcheck/features/argumentHandler/ArgumentHandler.java index ac29525c..3a006a80 100644 --- a/src/main/java/org/openmainframeproject/cobolcheck/features/argumentHandler/ArgumentHandler.java +++ b/src/main/java/org/openmainframeproject/cobolcheck/features/argumentHandler/ArgumentHandler.java @@ -142,10 +142,7 @@ private void processCommandLineArgumentArray(String[] args) { public void loadArgProgramPaths(){ String applicationSourceDirectory = Config.getApplicationSourceDirectoryPathString(); - if(options.isEmpty()){ - // return error when no program is passed - throw new CommandLineArgumentException(Messages.get("ERR030")); - } + boolean isProgramSpecified = false; for (OptionKey optionKey : options.keySet()) { if (optionKey.shortKey.equals(Constants.PROGRAMS_OPTION) || optionKey.longKey.equals(Constants.PROGRAMS_OPTION)) { String programArgs = options.get(optionKey).argumentValue; @@ -156,8 +153,13 @@ public void loadArgProgramPaths(){ newValue += "|"; } options.get(optionKey).argumentValue = newValue.substring(0, newValue.length()-1); + if(!programArgs.equals("")) isProgramSpecified = true; } } + if(!isProgramSpecified){ + // return error when no program is passed + throw new CommandLineArgumentException(Messages.get("ERR030")); + } } private OptionValue lookupOption(String requestedOption) {