Beispiel #1
0
 /**
  * Runs a particular command via appropriate command handler. The result is returned in the {@link
  * CommandResult} data structure.
  *
  * @param commandString The command string to be run. It includes command, its options, and
  *     arguments all separated by space. It is upto the relavant command handler to distinguish
  *     between comand, options, and arguments.
  * @return A {@link CommandResult} data structure which includes the result of running the
  *     command. In case of an error, it as well is stored in the returned data strucute.
  * @throws ParseException
  * @see CommandResult
  */
 public CommandResult handleCommand(String commandString) throws ParseException {
   CommandResult cmdResult = new CommandResult(commandString);
   if (!cmdResult.isError()) {
     CommandHandler handler = getCommandHandler(cmdResult.command);
     if (handler == null) {
       cmdResult.errMsg =
           "Command " + cmdResult.command + " is not supported\n" + "Type 'help' for more info";
     } else {
       handler.runCommand(cmdResult);
     }
   }
   return cmdResult;
 }