Convert the command to the screen document type.
@param strCommand The command text.
@param The standard document type (MAINT/DISPLAY/SELECT/MENU/etc).
493770
public int commandToDocType(String strCommand)
    {
        if (MessageLog.MESSAGE_SCREEN.equalsIgnoreCase(strCommand))
            return MessageLog.MESSAGE_SCREEN_MODE;
        if (MessageLog.SOURCE_SCREEN.equalsIgnoreCase(strCommand))
            return MessageLog.SOURCE_SCREEN_MODE;
        return super.commandToDocType(strCommand);
    }
883816
public Object doRemoteCommand(String strCommand, Map<String,Object> properties) throws RemoteException, DBException
    {
        Map<String,Object> propMenu = properties; // I NOW for a fact this is a Properties object.
        if (propMenu == null)
            propMenu = new Hashtable<String,Object>();
        if (strCommand != null)
            if (strCommand.length() > 0)
                if (strCommand.indexOf('=') == -1)
                    strCommand = DBParams.MENU + '=' + strCommand;  // If no param specified, it is a menu=
        Utility.parseArgs(propMenu, strCommand);
        String strMenu = (String)propMenu.get(DBParams.MENU);
        if ((strMenu == null) || (strMenu.length() == 0))
            strMenu = this.getProperty(DBParams.MENU);
        if ((strMenu == null) || (strMenu.length() == 0))
            strMenu = this.getProperty(DBParams.HOME);
        if ((strMenu == null) || (strMenu.length() == 0))
            strMenu = HtmlConstants.MAIN_MENU_KEY;
        
        if (strMenu != null)
        {
            this.setupSubMenus(strMenu);
            return Boolean.TRUE;
        }
        return super.doRemoteCommand(strCommand, properties);
    }
500565
public void usage(@Nullable String programName, @Nullable String groupName, String commandName, CommandMetadata command)
    {
        StringBuilder stringBuilder = new StringBuilder();
        usage(programName, groupName, commandName, command, stringBuilder);
        System.out.println(stringBuilder.toString());
    }
994389
public void printHtmlLink(PrintWriter out, String strTag, String strParams, String strData)
    {
        String strRecordClass = m_recDetail.getClass().getName();
        String strLink = HtmlConstants.SERVLET_LINK;
        strLink = Utility.addURLParam(strLink, DBParams.RECORD, strRecordClass);
        strLink = Utility.addURLParam(strLink, DBParams.COMMAND, ThinMenuConstants.FORM);
        if ((m_recDetail.getEditMode() == Constants.EDIT_IN_PROGRESS) || (m_recDetail.getEditMode() == Constants.EDIT_CURRENT))
        {
            try   {
                String strBookmark = m_recDetail.getHandle(DBConstants.OBJECT_ID_HANDLE).toString();
                strLink = Utility.addURLParam(strLink, DBConstants.STRING_OBJECT_ID_HANDLE, strBookmark);
            } catch (DBException ex)    {
                ex.printStackTrace();
            }
        }

        String strParam = this.getRecordOwner().getProperty(DBParams.MENUBARS);
        if (strParam != null)
            strLink = Utility.addURLParam(strLink, DBParams.MENUBARS, strParam);
        strParam = this.getRecordOwner().getProperty(DBParams.NAVMENUS);
        if (strParam != null)
            strLink = Utility.addURLParam(strLink, DBParams.NAVMENUS, strParam);
        strParam = this.getRecordOwner().getProperty(DBParams.LOGOS);
        if (strParam != null)
            strLink = Utility.addURLParam(strLink, DBParams.LOGOS, strParam);
        strParam = this.getRecordOwner().getProperty(DBParams.TRAILERS);
        if (strParam != null)
            strLink = Utility.addURLParam(strLink, DBParams.TRAILERS, strParam);
        strParam = this.getRecordOwner().getProperty(DBConstants.SYSTEM_NAME);
        if (strParam != null)
            strLink = Utility.addURLParam(strLink, DBConstants.SYSTEM_NAME, strParam);
        strParam = this.getRecordOwner().getProperty(DBConstants.MODE);
        if (strParam != null)
            strLink = Utility.addURLParam(strLink, DBConstants.MODE, strParam);
         
        out.print(strLink);
    }
1287133
public final void usage(String commandName, StringBuilder out, String indent) {
        String description = getCommandDescription(commandName);
        JCommander jc = commander.findCommandByAlias(commandName);

        if (description != null) {
            out.append(indent).append(description);
            out.append("\n");
        }
        jc.getUsageFormatter().usage(out, indent);
    }
1233458
@VisibleForTesting
    protected void setSttyMode(STTYMode mode) throws IOException {
        String[] cmd;
        if (mode == STTYMode.COOKED) {
            cmd = new String[]{"/bin/sh", "-c", "stty -raw echo </dev/tty"};
        } else {
            cmd = new String[]{"/bin/sh", "-c", "stty raw -echo </dev/tty"};
        }

        Process p = runtime.exec(cmd);

        try {
            p.waitFor();
        } catch (InterruptedException ie) {
            throw new IOException(ie.getMessage(), ie);
        }

        try (InputStreamReader in = new InputStreamReader(p.getErrorStream(), UTF_8);
             BufferedReader reader = new BufferedReader(in)) {
            String err = reader.readLine();
            if (err != null) {
                throw new IOException(err);
            }
        }
    }
305675
static public SFStatementType checkStageManageCommand(String sql)
  {
    if (sql == null)
    {
      return null;
    }

    String trimmedSql = sql.trim();

    // skip commenting prefixed with //
    while (trimmedSql.startsWith("//"))
    {
      logger.debug("skipping // comments in: \n{}", trimmedSql);

      if (trimmedSql.indexOf('\n') > 0)
      {
        trimmedSql = trimmedSql.substring(trimmedSql.indexOf('\n'));
        trimmedSql = trimmedSql.trim();
      }
      else
      {
        break;
      }

      logger.debug("New sql after skipping // comments: \n{}",
                   trimmedSql);

    }

    // skip commenting enclosed with /* */
    while (trimmedSql.startsWith("/*"))
    {
      logger.debug("skipping /* */ comments in: \n{}", trimmedSql);

      if (trimmedSql.indexOf("*/") > 0)
      {
        trimmedSql = trimmedSql.substring(trimmedSql.indexOf("*/") + 2);
        trimmedSql = trimmedSql.trim();
      }
      else
      {
        break;

      }
      logger.debug("New sql after skipping /* */ comments: \n{}", trimmedSql);

    }

    trimmedSql = trimmedSql.toLowerCase();

    if (trimmedSql.startsWith("put "))
    {
      return SFStatementType.PUT;
    }
    else if (trimmedSql.startsWith("get "))
    {
      return SFStatementType.GET;
    }
    else if (trimmedSql.startsWith("ls ") ||
             trimmedSql.startsWith("list "))
    {
      return SFStatementType.LIST;
    }
    else if (trimmedSql.startsWith("rm ") ||
             trimmedSql.startsWith("remove "))
    {
      return SFStatementType.REMOVE;
    }
    else
    {
      return null;
    }
  }
601523
@Override
    public void actionPerformed(ActionEvent e) {
        String cmd = e.getActionCommand();
        if (cmd.equals("Cut")) {
            consoleTextArea.cut();
        } else if (cmd.equals("Copy")) {
            consoleTextArea.copy();
        } else if (cmd.equals("Paste")) {
            consoleTextArea.paste();
        }
    }
865546
@Override
    protected void doHandle(CommandContext ctx) throws CommandLineException {

        final ParsedCommandLine args = ctx.getParsedCommandLine();
        final String action = this.action.getValue(args);
        if(action == null) {
            throw new CommandFormatException("Command is missing.");
        }

        if(action.equals("list")) {
            ctx.printColumns(getExistingCommands());
            return;
        }

        if(action.equals("add")) {
            final String nodePath = this.nodePath.getValue(args, true);
            final String propName = this.idProperty.getValue(args, false);
            final String cmdName = this.commandName.getValue(args, true);
            validateInput(ctx, nodePath, propName);

            if(cmdRegistry.getCommandHandler(cmdName) != null) {
                throw new CommandFormatException("Command '" + cmdName + "' already registered.");
            }
            cmdRegistry.registerHandler(new GenericTypeOperationHandler(cmdName, ctx, nodePath, propName), cmdName);
            return;
        }

        if(action.equals("remove")) {
            final String cmdName = this.commandName.getValue(args, true);
            CommandHandler handler = cmdRegistry.getCommandHandler(cmdName);
            if(!(handler instanceof GenericTypeOperationHandler)) {
                throw new CommandFormatException("Command '" + cmdName + "' is not a generic type command.");
            }
            cmdRegistry.remove(cmdName);
            return;
        }

        throw new CommandFormatException("Unexpected action: " + action);
    }
26072
public void actionPerformed(ActionEvent event) {
        String cmd = event.getActionCommand();
        if (cmd.equals(CUT)) {
            text.cut();
        } else if (cmd.equals(COPY)) {
            text.copy();
        } else if (cmd.equals(PASTE)) {
            text.paste();
        }
    }
1036727
def magictype(text, prompt_template="default", speed=1):
    
    echo_prompt(prompt_template)
    cursor_position = 0
    return_to_regular_type = False
    with raw_mode():
        while True:
            char = text[cursor_position : cursor_position + speed]
            in_char = getchar()
            if in_char in {ESC, CTRLC}:
                echo(carriage_return=True)
                raise click.Abort()
            elif in_char == TAB:
                return_to_regular_type = True
                break
            elif in_char == BACKSPACE:
                if cursor_position > 0:
                    echo("\b \b", nl=False)
                    cursor_position -= 1
            elif in_char in RETURNS:
                # Only return at end of command
                if cursor_position >= len(text):
                    echo("\r", nl=True)
                    break
            elif in_char == CTRLZ and hasattr(signal, "SIGTSTP"):
                # Background process
                os.kill(0, signal.SIGTSTP)
                # When doitlive is back in foreground, clear the terminal
                # and resume where we left off
                click.clear()
                echo_prompt(prompt_template)
                echo(text[:cursor_position], nl=False)
            else:
                if cursor_position < len(text):
                    echo(char, nl=False)
                    increment = min([speed, len(text) - cursor_position])
                    cursor_position += increment
    return return_to_regular_type
100351
@Override
    protected void doHandle(CommandContext ctx) throws CommandFormatException {
        BatchManager batchManager = ctx.getBatchManager();
        if(!batchManager.isBatchActive()) {
            throw new CommandFormatException("No active batch.");
        }
        Batch activeBatch = batchManager.getActiveBatch();
        List<BatchedCommand> commands = activeBatch.getCommands();
        if (!commands.isEmpty()) {
            for (int i = 0; i < commands.size(); ++i) {
                BatchedCommand cmd = commands.get(i);
                ctx.printLine("#" + (i + 1) + ' ' + cmd.getCommand());
            }
        } else {
            ctx.printLine("The batch is empty.");
        }
    }
608520
public Object doRemoteAction(String strCommand, Map<String, Object> properties) throws DBException, RemoteException
    {
        BaseTransport transport = this.createProxyTransport(DO_REMOTE_ACTION);
        transport.addParam(NAME, strCommand);   // Don't use COMMAND
        transport.addParam(PROPERTIES, properties);
        Object strReturn = transport.sendMessageAndGetReply();
        if (strReturn instanceof String)
        {   // Could be returning a session
            BaseSessionProxy session = this.checkForSession((String)strReturn);
            if (session != null)
                return session;
        }
        Object objReturn = transport.convertReturnObject(strReturn);
        return this.checkDBException(objReturn);
    }
365736
private void determineCommand() {
        command = null;
        commandStr = null;

        boolean tooManyCommands = false;
        for (Command c : Command.values()) {
            final String alias = c.getAlias();
            if (hasOption(alias)) {
                if (c == Command.HELP) {
                    // `--help` can be a command or just a long option for another command.
                    help = true;
                } else if (command == null) {
                    // Found a command option
                    command = c;
                    commandStr = alias;
                } else {
                    tooManyCommands = true;
                }
            }
        }

        if (tooManyCommands) {
            command = null;
            commandStr = null;

            if (!help) {
                reportable.error(format(
                        "You must specify only one command (%s).%n",
                        showCommandAliases()));
                printHelp(true);
            }
        }
        if (help && command == null) {
            // `--help` is considered as the command if no other command is provided.
            command = Command.HELP;
            commandStr = command.getAlias();

        } else if (command == null) {
        	// Print usage if no commands were specified
        	printUsage();
        	reportable.error("\n");
            reportable
                    .error("No command option given. Please specify one of:  "
                            + showCommandAliases());
            end();
        }
    }
757567
def control_command_select_string(title, text, control, string)
      command 'ControlCommand', [title, text, control, 'SelectString', string]
    end
839292
private function _addError($strCommand, $strMessage)
    {
        $index = count($this->_arrErrorList) + 1;
        $this->_arrErrorList[$index]['command'] = $strCommand;
        $this->_arrErrorList[$index]['message'] = $strMessage;
        $this->_errors++;
    }
271012
public static void displayMessageBox( String strMsg, final int iType, boolean bWrapText )
  {
    final String strWrappedMsg = bWrapText ? wrapText( strMsg ) : strMsg;

    Runnable logMsgBox = new Runnable()
    {
      public void run()
      {
        JOptionPane.showMessageDialog( getWindow(), strWrappedMsg, "", iType );
      }
    };

    if( EventQueue.isDispatchThread() )
    {
      logMsgBox.run();
    }
    else
    {
      try
      {
        EventQueue.invokeAndWait( logMsgBox );
      }
      catch( Throwable t )
      {
        t.printStackTrace();
      }
    }
  }