Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/main/java/org/apache/commons/cli/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,25 @@ public Options addOption(String opt, String longOpt, boolean hasArg, String desc
return this;
}

/**
* Add an option that contains a short-name and a long-name.
* This option is set as required.
* It may be specified as requiring an argument.
*
* @param opt Short single-character name of the option.
* @param longOpt Long multi-character name of the option.
* @param hasArg flag signally if an argument is required after this option
* @param description Self-documenting description
* @return the resulting Options instance
*/
public Options addRequiredOption(String opt, String longOpt, boolean hasArg, String description)
{
Option option = new Option(opt, longOpt, hasArg, description);
option.setRequired(true);
addOption(option);
return this;
}

/**
* Adds an option instance
*
Expand Down