public final class OptionFormatter extends Object
| Modifier and Type | Class | Description |
|---|---|---|
static class |
OptionFormatter.Builder |
Builds instances of
OptionFormatter. |
| Modifier and Type | Field | Description |
|---|---|---|
static Function<Option,String> |
COMPLEX_DEPRECATED_FORMAT |
A function to display a deprecated option with a "Deprecated" prefix that displays all deprecation information.
|
static String |
DEFAULT_ARG_NAME |
The default argument name: "arg".
|
static String |
DEFAULT_LONG_OPT_PREFIX |
Default prefix for long options: "--".
|
static String |
DEFAULT_OPT_ARG_SEPARATOR |
The default separator between the opt and/or longOpt and the argument name: " ".
|
static String |
DEFAULT_OPT_PREFIX |
Default prefix for short options: "-".
|
static String |
DEFAULT_OPT_SEPARATOR |
The default separator between options: ", ".
|
static String |
DEFAULT_SYNTAX_PREFIX |
The string to display at the beginning of the usage statement: "usage: ".
|
static Function<Option,String> |
NO_DEPRECATED_FORMAT |
A function to display a deprecated option with the "[Deprecated]" prefix.
|
static Function<Option,String> |
SIMPLE_DEPRECATED_FORMAT |
A function to display a deprecated option with the "[Deprecated]" prefix.
|
| Modifier and Type | Method | Description |
|---|---|---|
static OptionFormatter.Builder |
builder() |
Creates a new builder.
|
static OptionFormatter |
from(Option option) |
|
String |
getArgName() |
Gets the argument name wrapped in the argument name delimiters.
|
String |
getBothOpt() |
Gets both options separated by the specified option separator.
|
String |
getDescription() |
Gets the description for the option.
|
String |
getLongOpt() |
Gets the long Opt from the @{link Option} with the associate prefix.
|
String |
getOpt() |
Gets the Opt from the @{link Option} with the associate prefix.
|
String |
getSince() |
Gets the "since" value from the Option.
|
boolean |
isRequired() |
Gets the required flag from the enclosed
Option. |
String |
toOptional(String text) |
Wraps the provided text in the optional delimiters.
|
String |
toSyntaxOption() |
Gets the syntax format for this option.
|
String |
toSyntaxOption(boolean isRequired) |
Gets the syntax format for this option.
|
public static final String DEFAULT_ARG_NAME
public static final Function<Option,String> SIMPLE_DEPRECATED_FORMAT
public static final Function<Option,String> COMPLEX_DEPRECATED_FORMAT
public static final Function<Option,String> NO_DEPRECATED_FORMAT
public static final String DEFAULT_SYNTAX_PREFIX
public static final String DEFAULT_OPT_PREFIX
public static final String DEFAULT_LONG_OPT_PREFIX
public static final String DEFAULT_OPT_SEPARATOR
public static final String DEFAULT_OPT_ARG_SEPARATOR
public static OptionFormatter.Builder builder()
public static OptionFormatter from(Option option)
option - the option to format.public String getArgName()
public String getBothOpt()
public String getDescription()
public String getLongOpt()
public String getOpt()
public String getSince()
public boolean isRequired()
Option.Option.public String toOptional(String text)
text - the text to wrap.public String toSyntaxOption()
public String toSyntaxOption(boolean isRequired)
isRequired - if true the options is printed as a required option, otherwise it is optional.Copyright © 2002-2025 The Apache Software Foundation. All rights reserved.Apache Commons CLI | Issue management | Source repository