public class CLIInteraction extends Object
Maapi.getCLIInteraction(int)
method as is intended to be used from inside an action callbackModifier and Type | Method and Description |
---|---|
void |
cmd(String command)
Execute CLI command in ongoing CLI session.
|
void |
cmd(String command,
EnumSet<CLIInteractionFlag> flags)
Execute CLI command in ongoing CLI session.
|
void |
cmd(String command,
EnumSet<CLIInteractionFlag> flags,
String unhide)
Execute CLI command in ongoing CLI session.
|
MaapiInputStream |
cmdIO(String command,
EnumSet<CLIInteractionFlag> flags,
String unhide)
Execute CLI command in ongoing CLI session and output result on socket.
|
String |
get(String parameter)
Read CLI session parameter.
|
void |
printf(String fmt,
Object... arguments)
Write to the CLI using printf formatting.
|
String |
prompt(String promptStr,
boolean echo)
Prompt user for a string.
|
String |
prompt(String promptStr,
boolean echo,
int timeout)
This function does the same as prompt(String promptStr), but also takes a
timeout parameter, which controls how long (in seconds) to wait for input
before aborting.
|
String |
promptOneOf(String promptStr,
String[] choice,
boolean echo)
Prompt user for one of the strings given in the choice parameter.
|
String |
promptOneOf(String promptStr,
String[] choice,
boolean echo,
int timeout)
This function does the same as promptOneOf(String promptStr, String[]
choice, boolean echo), but also takes a timeout parameter.
|
String |
readEOF(boolean echo)
Read a multi line string from the CLI.
|
String |
readEOF(boolean echo,
int timeout)
This function does the same as readEOF(boolean echo), but also takes a
timeout parameter, which indicates how long the user may be idle (in
seconds) before the reading is aborted.
|
void |
set(String parameter,
String value)
Set CLI session parameter.
|
void |
write(String str)
Write to the CLI.
|
public String prompt(String promptStr, boolean echo) throws IOException, ConfException
promptStr
- echo
- IOException
ConfException
public String prompt(String promptStr, boolean echo, int timeout) throws IOException, ConfException
promptStr
- echo
- timeout
- IOException
ConfException
public String promptOneOf(String promptStr, String[] choice, boolean echo) throws IOException, ConfException
For example:
CLIInteraction cli = maapi.getCLIInteraction(usid); String result = cli.promptOneOf("Do you want to proceed (yes/no): ", new String[] { "yes", "no" }, true);
The user can enter a unique prefix of the choice but the value returned will always be one of the strings provided in the choice parameter. If the user enters a value not in choice he will automatically be re-prompted.
For example:
Do you want to proceed (yes/no): maybe The value must be one of: yes,no. Do you want to proceed (yes/no):
promptStr
- choice
- echo
- IOException
ConfException
public String promptOneOf(String promptStr, String[] choice, boolean echo, int timeout) throws IOException, ConfException
promptStr
- choice
- echo
- timeout
- IOException
ConfException
public String readEOF(boolean echo) throws IOException, ConfException
echo
- IOException
ConfException
public String readEOF(boolean echo, int timeout) throws IOException, ConfException
echo
- timeout
- IOException
ConfException
public void write(String str) throws IOException, ConfException
str
- IOException
ConfException
public String get(String parameter) throws IOException, ConfException
parameter
- IOException
ConfException
public void set(String parameter, String value) throws IOException, ConfException
parameter
- value
- IOException
ConfException
public void cmd(String command) throws IOException, ConfException
command
- IOException
ConfException
public void cmd(String command, EnumSet<CLIInteractionFlag> flags) throws IOException, ConfException
command
- flags
- IOException
ConfException
public void cmd(String command, EnumSet<CLIInteractionFlag> flags, String unhide) throws IOException, ConfException
command
- flags
- unhide
- IOException
ConfException
public void printf(String fmt, Object... arguments) throws IOException, ConfException
fmt
- arguments
- IOException
ConfException
public MaapiInputStream cmdIO(String command, EnumSet<CLIInteractionFlag> flags, String unhide) throws IOException, ConfException
command
- flags
- unhide
- IOException
ConfException