| Modifier and Type | Field and Description |
|---|---|
protected String |
description |
protected boolean |
hidden |
protected String |
name |
protected List<Option> |
options |
protected int |
priority |
protected String |
summary |
| Constructor and Description |
|---|
DefaultCLI() |
| Modifier and Type | Method and Description |
|---|---|
CLI |
addArgument(Argument arg)
Adds an argument.
|
CLI |
addArguments(List<Argument> args)
Adds a set of arguments.
|
CLI |
addOption(Option option)
Adds an option.
|
CLI |
addOptions(List<Option> options)
Adds a set of options.
|
Argument |
getArgument(int index)
Gets an
Argument based on its index. |
Argument |
getArgument(String name)
Gets an
Argument based on its name (argument name). |
List<Argument> |
getArguments()
Gets the list of defined arguments.
|
String |
getDescription() |
String |
getName() |
Option |
getOption(String name)
Gets an
Option based on its name (short name, long name or argument name). |
List<Option> |
getOptions()
Gets the list of options.
|
int |
getPriority() |
String |
getSummary() |
boolean |
isHidden()
Checks whether or not the current
CLI instance is hidden. |
CommandLine |
parse(List<String> arguments)
Parses the user command line interface and create a new
CommandLine containing extracting values. |
CommandLine |
parse(List<String> arguments,
boolean validate)
Parses the user command line interface and create a new
CommandLine containing extracting values. |
CLI |
removeArgument(int index)
Removes an argument identified by its index.
|
CLI |
removeOption(String name)
Removes an option identified by its name.
|
CLI |
setArguments(List<Argument> args)
Sets the list of arguments.
|
CLI |
setDescription(String desc) |
CLI |
setHidden(boolean hidden)
Sets whether or not the current instance of
CLI must be hidden. |
CLI |
setName(String name)
Sets the name of the CLI.
|
CLI |
setOptions(List<Option> options)
Sets the list of arguments.
|
CLI |
setPriority(int priority)
Sets the priority of the CLI.
|
CLI |
setSummary(String summary)
Sets the summary of the CLI.
|
CLI |
usage(StringBuilder builder)
Generates the usage / help of the current
CLI. |
CLI |
usage(StringBuilder builder,
String prefix)
Generates the usage / help of the current
CLI. |
protected String name
protected int priority
protected String description
protected String summary
protected boolean hidden
public CommandLine parse(List<String> arguments)
CommandLine containing extracting values.public CommandLine parse(List<String> arguments, boolean validate)
CommandLine containing extracting values.public CLI setName(String name)
CLIpublic String getDescription()
getDescription in interface CLIpublic CLI setDescription(String desc)
setDescription in interface CLIpublic String getSummary()
getSummary in interface CLIpublic CLI setSummary(String summary)
CLIsetSummary in interface CLIsummary - the summaryCLI instancepublic boolean isHidden()
CLICLI instance is hidden.public CLI setHidden(boolean hidden)
CLICLI must be hidden. Hidden CLI are not listed when
displaying usages / help messages. In other words, hidden commands are for power user.public List<Option> getOptions()
CLIgetOptions in interface CLIpublic CLI addOption(Option option)
CLIpublic CLI addOptions(List<Option> options)
CLICLI.setOptions(List)}, this method does not remove the existing options.
The given list is appended to the existing list.addOptions in interface CLIoptions - the options, must not be nullCLI instancepublic CLI setOptions(List<Option> options)
CLIsetOptions in interface CLIoptions - the list of options, must not be nullCLI instancepublic List<Argument> getArguments()
CLIgetArguments in interface CLIpublic CLI addArgument(Argument arg)
CLIaddArgument in interface CLIarg - the argument, must not be nullCLI instancepublic CLI addArguments(List<Argument> args)
CLICLI.setArguments(List), this method does not remove the existing arguments.
The given list is appended to the existing list.addArguments in interface CLIargs - the arguments, must not be nullCLI instancepublic CLI setArguments(List<Argument> args)
CLIsetArguments in interface CLIargs - the list of arguments, must not be nullCLI instancepublic Option getOption(String name)
CLIOption based on its name (short name, long name or argument name).public Argument getArgument(String name)
CLIArgument based on its name (argument name).getArgument in interface CLIname - the name of the argument, must not be nullArgument, null if not found.public Argument getArgument(int index)
CLIArgument based on its index.getArgument in interface CLIindex - the index, must be positive or zero.Argument, null if not found.public CLI removeOption(String name)
CLIremoveOption in interface CLIname - the option nameCLI instancepublic CLI removeArgument(int index)
CLIremoveArgument in interface CLIindex - the argument indexCLI instancepublic CLI usage(StringBuilder builder)
CLICLI.public CLI usage(StringBuilder builder, String prefix)
CLICLI.public int getPriority()
getPriority in interface CLIpublic CLI setPriority(int priority)
CLIsetPriority in interface CLIpriority - the priorityCLI instanceCopyright © 2020. All rights reserved.