Skip to content

Commit 5159f98

Browse files
committed
Add optional argument to help output
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/branches/avalon-implementation@539899 13f79535-47bb-0310-9956-ffa450edef68
1 parent ebe542f commit 5159f98

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/java/org/apache/commons/cli/avalon/CLUtil.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ public static final StringBuffer describeOptions( final CLOptionDescriptor[] opt
4646
final String name = options[i].getName();
4747
String description = options[i].getDescription();
4848
int flags = options[i].getFlags();
49+
boolean argumentOptional =
50+
((flags & CLOptionDescriptor.ARGUMENT_OPTIONAL) ==
51+
CLOptionDescriptor.ARGUMENT_OPTIONAL);
4952
boolean argumentRequired =
5053
((flags & CLOptionDescriptor.ARGUMENT_REQUIRED) ==
51-
CLOptionDescriptor.ARGUMENT_REQUIRED);
54+
CLOptionDescriptor.ARGUMENT_REQUIRED);
5255
boolean twoArgumentsRequired =
5356
((flags & CLOptionDescriptor.ARGUMENTS_REQUIRED_2) ==
54-
CLOptionDescriptor.ARGUMENTS_REQUIRED_2);
57+
CLOptionDescriptor.ARGUMENTS_REQUIRED_2);
5558
boolean needComma = false;
5659
if( twoArgumentsRequired )
5760
{
@@ -78,6 +81,10 @@ public static final StringBuffer describeOptions( final CLOptionDescriptor[] opt
7881
sb.append( name );
7982
}
8083

84+
if (argumentOptional)
85+
{
86+
sb.append(" [[=]<argument>]");
87+
}
8188
if( argumentRequired )
8289
{
8390
sb.append( " <argument>" );

0 commit comments

Comments
 (0)