Skip to content

Commit 3062371

Browse files
author
Robert James Oxspring
committed
Added "missing required option" message
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/trunk@130103 13f79535-47bb-0310-9956-ffa450edef68
1 parent 6270b29 commit 3062371

4 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/java/org/apache/commons/cli2/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ cli.error.missing.values = Missing value(s)
44
cli.error.missing.option = Missing option
55
cli.error.burst = Could not burst "{0}" while processing
66
cli.error.badproperty = Could not understand property: {0}
7+
cli.error.missing.required = Missing required option

src/java/org/apache/commons/cli2/option/Command.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public Set getTriggers() {
129129
public void validate(WriteableCommandLine commandLine)
130130
throws OptionException {
131131
if (isRequired() && !commandLine.hasOption(this)) {
132-
throw new OptionException(this);
132+
throw new OptionException(this,"cli.error.missing.required", getPreferredName());
133133
}
134134

135135
super.validate(commandLine);

src/java/org/apache/commons/cli2/option/DefaultOption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public Set getPrefixes() {
184184
public void validate(WriteableCommandLine commandLine)
185185
throws OptionException {
186186
if (isRequired() && !commandLine.hasOption(this)) {
187-
throw new OptionException(this);
187+
throw new OptionException(this,"cli.error.missing.required", getPreferredName());
188188
}
189189

190190
super.validate(commandLine);

src/java/org/apache/commons/cli2/option/Switch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public Set getPrefixes() {
165165
public void validate(WriteableCommandLine commandLine)
166166
throws OptionException {
167167
if (isRequired() && !commandLine.hasOption(this)) {
168-
throw new OptionException(this);
168+
throw new OptionException(this,"cli.error.missing.required", getPreferredName());
169169
}
170170

171171
super.validate(commandLine);

0 commit comments

Comments
 (0)