Package io.micronaut.core.cli
Interface CommandLine
-
public interface CommandLine
Represents the parsed command line options.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
CommandLine.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.Builder
build()
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.String
getRemainingArgsString()
java.lang.String
getRemainingArgsWithOptionsString()
java.util.Properties
getSystemProperties()
java.util.Map<java.lang.String,java.lang.Object>
getUndeclaredOptions()
boolean
hasOption(java.lang.String name)
java.util.Map.Entry<java.lang.String,java.lang.Object>
lastOption()
java.lang.Object
optionValue(java.lang.String name)
The value of an option.static CommandLine
parse(java.lang.String... args)
Parse a new command line with the default options.CommandLine
parseNew(java.lang.String[] args)
Parses a newCommandLine
instance 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 newCommandLine
instance that combines this instance with the given arguments.- Parameters:
args
- The arguments- Returns:
- A new
CommandLine
instance
-
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
-
-