Skip to content

Commit 1b0a32d

Browse files
committed
Added patch to CLI-141 that makes Option Serializable - Thanks to Henning and Bjorn
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x@596140 13f79535-47bb-0310-9956-ffa450edef68
1 parent 4e5351d commit 1b0a32d

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/java/org/apache/commons/cli/Option.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.apache.commons.cli;
1818

19+
import java.io.Serializable;
1920
import java.util.ArrayList;
2021

2122
/** <p>Describes a single command-line option. It maintains
@@ -33,7 +34,9 @@
3334
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
3435
* @version $Revision$
3536
*/
36-
public class Option implements Cloneable {
37+
public class Option implements Cloneable, Serializable {
38+
39+
private static final long serialVersionUID = 1L;
3740

3841
/** constant that specifies the number of argument values has
3942
not been specified */
@@ -48,9 +51,6 @@ public class Option implements Cloneable {
4851
/** longOpt is the long representation of the option */
4952
private String longOpt;
5053

51-
/** hasArg specifies whether this option has an associated argument */
52-
private boolean hasArg;
53-
5454
/** argName specifies the name of the argument for this option */
5555
private String argName = "arg";
5656

@@ -136,7 +136,6 @@ public Option(String opt, String longOpt, boolean hasArg,
136136
this.numberOfArgs = 1;
137137
}
138138

139-
this.hasArg = hasArg;
140139
this.description = description;
141140
}
142141

@@ -571,9 +570,11 @@ public String toString()
571570

572571
buf.append(" ");
573572

574-
if (hasArg)
573+
if (hasArgs())
575574
{
576-
buf.append("+ARG");
575+
buf.append("[ARG...]");
576+
} else if (hasArg()) {
577+
buf.append(" [ARG]");
577578
}
578579

579580
buf.append(" :: ").append(this.description);

0 commit comments

Comments
 (0)