From d6ef121a1728987a6e776922f6683c3dada3c475 Mon Sep 17 00:00:00 2001 From: alee Date: Thu, 3 Dec 2009 21:21:48 +0000 Subject: fixes for BZ 510774,531162,504030, 493418 git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@877 c9f7a03b-bd48-0410-a16d-cbbf54688b0b --- pki/base/silent/src/argparser/ArgParser.java | 61 ++++++++++++++++++---------- 1 file changed, 40 insertions(+), 21 deletions(-) (limited to 'pki/base/silent/src/argparser/ArgParser.java') diff --git a/pki/base/silent/src/argparser/ArgParser.java b/pki/base/silent/src/argparser/ArgParser.java index cd1b777de..46251787f 100755 --- a/pki/base/silent/src/argparser/ArgParser.java +++ b/pki/base/silent/src/argparser/ArgParser.java @@ -676,6 +676,7 @@ public class ArgParser int type; int numValues; boolean vectorResult = false; + boolean required = true; String helpMsg = null; String valueDesc = null; @@ -1682,28 +1683,35 @@ public class ArgParser // skip white space following conversion information scanner.skipWhiteSpace(); - // get the help message, if any + // get the help message, if any + + if (!scanner.atEnd()) + { if (scanner.getc() != '#') + { throw new IllegalArgumentException + ("Illegal character(s), expecting '#'"); + } + String helpInfo = scanner.substring (scanner.getIndex()); + // look for second '#'. If there is one, then info + // between the first and second '#' is the value descriptor. + int k = helpInfo.indexOf ("#"); + if (k != -1) + { rec.valueDesc = helpInfo.substring (0, k); + rec.helpMsg = helpInfo.substring (k+1); + } + else + { rec.helpMsg = helpInfo; + } + } + else + { rec.helpMsg = ""; + } + + // parse helpMsg for required/optional information if present + // default to required + if (rec.helpMsg.indexOf("(optional") != -1) { + rec.required = false; + } - if (!scanner.atEnd()) - { if (scanner.getc() != '#') - { throw new IllegalArgumentException - ("Illegal character(s), expecting '#'"); - } - String helpInfo = scanner.substring (scanner.getIndex()); - // look for second '#'. If there is one, then info - // between the first and second '#' is the value descriptor. - int k = helpInfo.indexOf ("#"); - if (k != -1) - { rec.valueDesc = helpInfo.substring (0, k); - rec.helpMsg = helpInfo.substring (k+1); - } - else - { rec.helpMsg = helpInfo; - } - } - else - { rec.helpMsg = ""; - } // add option information to match list if (rec.convertCode == 'h' && firstHelpOption == defaultHelpOption) { matchList.remove (defaultHelpOption); @@ -1743,6 +1751,17 @@ public class ArgParser return null; } + public void checkRequiredArgs() { + for (int i=1; i