java.lang.Object
io.github.mmm.cli.CliArgs
A simple wrapper for the arguments of a
main method from a command-line-interface (CLI). Allows to easily
iterate and parse these arguments.- Since:
- 1.0.0
- See Also:
-
Constructor Details
-
CliArgs
The constructor.- Parameters:
args- the command-line arguments frommainmethod.
-
-
Method Details
-
getFirst
- Returns:
- the first
CliArgument. - See Also:
-
getLastOption
- Returns:
- the last
CliOptionfrom the arguments.
-
isEmpty
public boolean isEmpty()- Returns:
trueif empty,falseotherwise.
-
getSize
public int getSize()- Returns:
- the number of
CliArguments.
-
getDuplicatedOptions
-
getOption
- Parameters:
opt- theoption string(e.g. "-h" or "--help" for help option).- Returns:
- the requested
CliOptionornullif no suchCliOptionexists. - See Also:
-
getOption
- Parameters:
options- the array ofoption string(e.g. "-h" or "--help" for help option).- Returns:
- the first matching
CliOptionornullif none of the givenoptionsexists.
-
getOption
- Parameters:
unique- -trueif not more than one of the givenoptionsshould be defined (or aCliDuplicateOptionAliasExceptionis thrown),falseotherwise. Set this flag totruewhen you provide multiple synonym options such as ashortand along option.options- the array ofoption string(e.g. "-h" or "--help" for help option).- Returns:
- the first matching
CliOptionornullif none of the givenoptionsexists. - Throws:
CliDuplicateOptionAliasException- in caseuniqueistrueand two of the givenoptionshave been found.
-
getOption
- Parameters:
unique- -trueif not more than one of the givenoptionsshould be defined (or aCliDuplicateOptionAliasExceptionis thrown),falseotherwise. Set this flag totruewhen you provide multiple synonym options such as ashortand along option.options- the Collection ofoption string(e.g. "-h" or "--help" for help option).- Returns:
- the first matching
CliOptionornullif none of the givenoptionsexists. - Throws:
CliDuplicateOptionAliasException- in caseuniqueistrueand two of the givenoptionshave been found.
-
getOriginalArguments
- Returns:
- the original arguments given at
construction.
-
getOriginalArgumentsAsString
- Returns:
- the original arguments as a single command-line
String.
-
toString
-