Package com.powsybl.tools
Class ToolOptions
java.lang.Object
com.powsybl.tools.ToolOptions
Wrapper around
CommandLine
to provide a more user friendly syntax,
in particular based on Optional
s.- Author:
- Sylvain Leclerc <sylvain.leclerc at rte-france.com>
-
Constructor Summary
ConstructorDescriptionToolOptions
(org.apache.commons.cli.CommandLine line, ToolRunningContext context) ToolOptions
(org.apache.commons.cli.CommandLine line, FileSystem fileSystem) -
Method Summary
Modifier and TypeMethodDescriptionIf exists, return the option value as a double.If exists, return the option value as an enum.If exists, return the option value as a float.If exists, return the option value as an int.If exists, return the option value as a file systemPath
.If exists, return the option value as a string.<T> Optional<T>
If exists, return the option value parsed with the provided parser.If exists, return the option value as a list of strings, assuming they were provided as a comma separated list.boolean
Return true if the option is defined.
-
Constructor Details
-
ToolOptions
-
ToolOptions
-
-
Method Details
-
getValue
If exists, return the option value as a string.- Parameters:
option
- The option name- Returns:
- The option value as a string if it exists, otherwise empty.
-
getValue
If exists, return the option value parsed with the provided parser.- Parameters:
option
- The option nameparser
- A function to transform the value from string to target type.- Returns:
- The option value parsed with the provided parser if it exists, otherwise empty.
-
getInt
If exists, return the option value as an int.- Parameters:
option
- The option name- Returns:
- The option value as an int if it exists, otherwise empty.
-
getFloat
If exists, return the option value as a float.- Parameters:
option
- The option name- Returns:
- The option value as a float if it exists, otherwise empty.
-
getDouble
If exists, return the option value as a double.- Parameters:
option
- The option name- Returns:
- The option value as a double if it exists, otherwise empty.
-
getValues
If exists, return the option value as a list of strings, assuming they were provided as a comma separated list.- Parameters:
option
- The option name- Returns:
- The option value as a list of strings if it exists, otherwise empty.
-
getEnum
If exists, return the option value as an enum.- Parameters:
option
- The option nameclazz
- The enum class- Returns:
- The option value as as an enum. if it exists, otherwise empty.
-
hasOption
Return true if the option is defined.- Parameters:
option
- The option name- Returns:
true
if the option is defined.
-
getPath
If exists, return the option value as a file systemPath
.- Parameters:
option
- The option name- Returns:
- The option value as a double if it exists, otherwise empty.
-