Package readycli
Class CommandContext
java.lang.Object
readycli.CommandContext
public final class CommandContext
extends java.lang.Object
Collects all the information that results from command parsing, i.e. actual
values of the required arguments and options, and the input and the output
streams used to interact with the user. The instances of this class are
created by the
Command class and submitted to a
CommandExecutor when the command is parsed.- Author:
- Salvatore Giampa'
-
Field Summary
Fields Modifier and Type Field Description java.util.Map<java.lang.String,java.lang.String>argumentsContains all values of all arguments.java.io.InputStreaminThe input stream used to interact with the user.java.util.Map<java.lang.String,OptionValues>optionsContains all values of all options.java.io.PrintStreamoutThe output stream used to interact with the user. -
Method Summary
Modifier and Type Method Description java.lang.StringgetArgument(java.lang.String name)Gets the value of an argument.OptionValuesgetOption(java.lang.String name)Gets the parameter values of an option.
Invoking this method, has the same effect of the following code:
context.options.get(name);
-
Field Details
-
arguments
public final java.util.Map<java.lang.String,java.lang.String> argumentsContains all values of all arguments. This is an unmodifiable map.
- Key: argument name;
- Value: argument value;
-
options
Contains all values of all options. This is an unmodifiable map.
- Key: option name;
- Value: option values;
-
out
public final java.io.PrintStream outThe output stream used to interact with the user. -
in
public final java.io.InputStream inThe input stream used to interact with the user.
-
-
Method Details
-
getArgument
public java.lang.String getArgument(java.lang.String name)Gets the value of an argument.
Invoking this method, has the same effect of the following code:
context.arguments.get(name);- Parameters:
name- the name of the argument- Returns:
- the string value of the argument
-
getOption
Gets the parameter values of an option.
Invoking this method, has the same effect of the following code:
context.options.get(name);- Parameters:
name- the name of the option- Returns:
- an
OptionValuesobject containing the values of the option
-