Package io.micronaut.core.cli
Interface CommandLine
-
public interface CommandLineRepresents the parsed command line options.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceCommandLine.Builder<T extends CommandLine.Builder>A build for constructing a command line parser.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static CommandLine.Builderbuild()Build and parse a new command line.java.util.Map<Option,java.lang.Object>getOptions()java.lang.String[]getRawArguments()java.util.List<java.lang.String>getRemainingArgs()java.lang.StringgetRemainingArgsString()java.lang.StringgetRemainingArgsWithOptionsString()java.util.PropertiesgetSystemProperties()java.util.Map<java.lang.String,java.lang.Object>getUndeclaredOptions()booleanhasOption(java.lang.String name)java.util.Map.Entry<java.lang.String,java.lang.Object>lastOption()java.lang.ObjectoptionValue(java.lang.String name)The value of an option.static CommandLineparse(java.lang.String... args)Parse a new command line with the default options.CommandLineparseNew(java.lang.String[] args)Parses a newCommandLineinstance that combines this instance with the given arguments.
-
-
-
Method Detail
-
getRemainingArgs
java.util.List<java.lang.String> getRemainingArgs()
- Returns:
- The remaining arguments after the command name
-
getSystemProperties
java.util.Properties getSystemProperties()
- Returns:
- The system properties specified
-
getOptions
java.util.Map<Option,java.lang.Object> getOptions()
- Returns:
- The declared option values
-
hasOption
boolean hasOption(java.lang.String name)
- Parameters:
name- The name of the option- Returns:
- Whether the given option is specified
-
optionValue
java.lang.Object optionValue(java.lang.String name)
The value of an option.- Parameters:
name- The option- Returns:
- The value
-
lastOption
java.util.Map.Entry<java.lang.String,java.lang.Object> lastOption()
- Returns:
- The last specified option
-
getRemainingArgsString
java.lang.String getRemainingArgsString()
- Returns:
- The remaining args as one big string
-
getRemainingArgsWithOptionsString
java.lang.String getRemainingArgsWithOptionsString()
- Returns:
- The remaining args as one big string without undeclared options
-
getUndeclaredOptions
java.util.Map<java.lang.String,java.lang.Object> getUndeclaredOptions()
- Returns:
- Any undeclared options
-
parseNew
CommandLine parseNew(java.lang.String[] args)
Parses a newCommandLineinstance that combines this instance with the given arguments.- Parameters:
args- The arguments- Returns:
- A new
CommandLineinstance
-
getRawArguments
java.lang.String[] getRawArguments()
- Returns:
- The raw unparsed arguments
-
build
static CommandLine.Builder build()
Build and parse a new command line.- Returns:
- The builder
-
parse
static CommandLine parse(java.lang.String... args)
Parse a new command line with the default options.- Parameters:
args- The arguments- Returns:
- The command line
-
-