From 7338eaba1518719c1df67f1e689ddd53ebc9d9fe Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 20 Jan 2015 14:45:13 +0000
Subject: [PATCH] Reverted some changes from r11605 since Eclipse lied to me...
---
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java | 39 +++++++++++++++++++++++++++++++++++----
1 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
index 25a46b2..aeb2d13 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
@@ -178,7 +178,7 @@
* properties file, no-prompt etc. These will appear toward the bottom of
* the usage statement.
*/
- private final ArgumentGroup ioArgGroup = new ArgumentGroup(
+ protected final ArgumentGroup ioArgGroup = new ArgumentGroup(
INFO_DESCRIPTION_IO_ARGS.get(), Integer.MIN_VALUE + 1);
/**
@@ -273,6 +273,22 @@
* has already been defined.
*/
public void addArgument(final Argument argument) throws ArgumentException {
+ addArgument(argument, null);
+ }
+
+ /**
+ * Adds the provided argument to the set of arguments handled by this
+ * parser.
+ *
+ * @param argument
+ * The argument to be added.
+ * @param group
+ * The argument group to which the argument belongs.
+ * @throws ArgumentException
+ * If the provided argument conflicts with another argument that
+ * has already been defined.
+ */
+ public void addArgument(final Argument argument, ArgumentGroup group) throws ArgumentException {
final Character shortID = argument.getShortIdentifier();
if (shortID != null && shortIDMap.containsKey(shortID)) {
final String conflictingName = shortIDMap.get(shortID).getName();
@@ -316,7 +332,9 @@
argumentList.add(argument);
- final ArgumentGroup group = getStandardGroup(argument);
+ if (group == null) {
+ group = getStandardGroup(argument);
+ }
group.addArgument(argument);
argumentGroups.add(group);
}
@@ -327,6 +345,20 @@
}
/**
+ * Adds the provided argument to the set of arguments handled by this parser
+ * and puts the argument in the default group.
+ *
+ * @param argument
+ * The argument to be added.
+ * @throws ArgumentException
+ * If the provided argument conflicts with another argument that
+ * has already been defined.
+ */
+ protected void addDefaultArgument(final Argument argument) throws ArgumentException {
+ addArgument(argument, defaultArgGroup);
+ }
+
+ /**
* Indicates whether this parser will allow unnamed trailing arguments.
* These will be arguments at the end of the list that are not preceded by
* either a long or short identifier and will need to be manually parsed by
@@ -1375,8 +1407,6 @@
final Character shortID = a.getShortIdentifier();
final String longID = a.getLongIdentifier();
if (shortID != null) {
- final int currentLength = buffer.length();
-
if (isUsageArgument(a)) {
buffer.append("-?, ");
}
@@ -1399,6 +1429,7 @@
newBuffer.append(a.getValuePlaceholder());
}
+ final int currentLength = buffer.length();
final int lineLength = (buffer.length() - currentLength) + newBuffer.length();
if (lineLength > MAX_LINE_WIDTH) {
buffer.append(EOL);
--
Gitblit v1.10.0