Class CLIInteraction

Object
com.tailf.maapi.CLIInteraction

public class CLIInteraction extends Object
Get CLI Interaction class for interaction with the user via the CLI. This class is retrieved using the Maapi.getCLIInteraction(int) method as is intended to be used from inside an action callback
  • Method Details

    • prompt

      public String prompt(String promptStr, boolean echo) throws IOException, ConfException
      Prompt user for a string. The echo parameter is used to control if the input should be echoed or not. If set to true all input will be visible and if set to false only stars will be shown instead of the actual characters entered by the user. The resulting user string is returned.
      Parameters:
      promptStr -
      echo -
      Returns:
      String
      Throws:
      IOException
      ConfException
    • prompt

      public String prompt(String promptStr, boolean echo, int timeout) throws IOException, ConfException
      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.
      Parameters:
      promptStr -
      echo -
      timeout -
      Returns:
      String
      Throws:
      IOException
      ConfException
    • promptOneOf

      public String promptOneOf(String promptStr, String[] choice, boolean echo) throws IOException, ConfException
      Prompt user for one of the strings given in the choice parameter.

      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):
       

      Parameters:
      promptStr -
      choice -
      echo -
      Returns:
      String
      Throws:
      IOException
      ConfException
    • promptOneOf

      public String promptOneOf(String promptStr, String[] choice, boolean echo, int timeout) throws IOException, ConfException
      This function does the same as promptOneOf(String promptStr, String[] choice, boolean echo), but also takes a timeout parameter. If no activity is seen for timeout seconds an error is thrown
      Parameters:
      promptStr -
      choice -
      echo -
      timeout -
      Returns:
      String
      Throws:
      IOException
      ConfException
    • readEOF

      public String readEOF(boolean echo) throws IOException, ConfException
      Read a multi line string from the CLI. The user has to end the input using ctrl-D. The entered characters is returned as a String. The echo parameters controls if the entered characters should be echoed or not. If set to true they will be visible and if set to false stars will be echoed instead.
      Parameters:
      echo -
      Returns:
      String
      Throws:
      IOException
      ConfException
    • readEOF

      public String readEOF(boolean echo, int timeout) throws IOException, ConfException
      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.
      Parameters:
      echo -
      timeout -
      Returns:
      String
      Throws:
      IOException
      ConfException
    • write

      public void write(String str) throws IOException, ConfException
      Write to the CLI.
      Parameters:
      str -
      Throws:
      IOException
      ConfException
    • get

      public String get(String parameter) throws IOException, ConfException
      Read CLI session parameter.
      Parameters:
      parameter -
      Returns:
      String
      Throws:
      IOException
      ConfException
    • set

      public void set(String parameter, String value) throws IOException, ConfException
      Set CLI session parameter.
      Parameters:
      parameter -
      value -
      Throws:
      IOException
      ConfException
    • cmd

      public void cmd(String command) throws IOException, ConfException
      Execute CLI command in ongoing CLI session.
      Parameters:
      command -
      Throws:
      IOException
      ConfException
    • cmd

      public void cmd(String command, EnumSet<CLIInteractionFlag> flags) throws IOException, ConfException
      Execute CLI command in ongoing CLI session. The flags field is used to disable certain checks during the execution. The value is a EnumSet of the enumeration CLIInteractionFlag.
      Parameters:
      command -
      flags -
      Throws:
      IOException
      ConfException
    • cmd

      public void cmd(String command, EnumSet<CLIInteractionFlag> flags, String unhide) throws IOException, ConfException
      Execute CLI command in ongoing CLI session. The flags field is used to disable certain checks during the execution. The value is a EnumSet of the enumeration CLIInteractionFlag. The unhide parameter is used for passing a hide groups which is unhidden during the execution of the command.
      Parameters:
      command -
      flags -
      unhide -
      Throws:
      IOException
      ConfException
    • printf

      public void printf(String fmt, Object... arguments) throws IOException, ConfException
      Write to the CLI using printf formatting. This
      Parameters:
      fmt -
      arguments -
      Throws:
      IOException
      ConfException
    • cmdIO

      public MaapiInputStream cmdIO(String command, EnumSet<CLIInteractionFlag> flags, String unhide) throws IOException, ConfException
      Execute CLI command in ongoing CLI session and output result on socket. The flags field is used to disable certain checks during the execution. The value is a EnumSet of the enumeration CLIInteractionFlag. The unhide parameter is used for passing a hide groups which is unhidden during the execution of the command. Data is returned as a MaapiInputStream that is read until EOF.
      Parameters:
      command -
      flags -
      unhide -
      Returns:
      MaapiInputStream
      Throws:
      IOException
      ConfException