Example #1
0
        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="input">The input.</param>
        public void executeCommand(String input)
        {
            lastInput = input;


            String input_proper = input.Trim().ToLower();

            response.getLastLine(true);



            switch (encode)
            {
            case aceCommandConsoleIOEncode.none:

                break;

            case aceCommandConsoleIOEncode.dos:
                input_proper = input_proper.toDosCharacters(toDosCharactersMode.toCleanChars, true);
                break;

            case aceCommandConsoleIOEncode.dosx:
                input_proper = input_proper.toDosCharacters(toDosCharactersMode.toCleanAndXChars, true);
                break;
            }

            aceCommandEntry entry = new aceCommandEntry(this, input);

            if (entry.isEmptyLine)
            {
                return;
            }

            if (entry.isSyntaxError)
            {
                output.AppendLine("Syntax error for entry: " + input);
                output.AppendLine(entry.errorMessage);
            }
            else
            {
                Boolean doInvoke = true;

                switch (entry.specialFunction)
                {
                case commandLineSpecialFunction.askForParameters:
                    foreach (var par in entry.marg.paramSet)
                    {
                        throw new NotImplementedException();
                        // par.setValueDirect(aceTerminalInput.AskFor(par.info.sPE, par.value));
                    }
                    //entry.marg.paramSet.

                    break;

                case commandLineSpecialFunction.helpOnCommand:
                    doInvoke = false;
                    commandSetTree.GetCommands(entry.command).ReportCommands(response);

                    break;

                case commandLineSpecialFunction.none:
                    break;
                }


                if (entry.invoke())
                {
                    if (saveClipboard)
                    {
                        clipboard.clipboardSetText(response.getLastLine());
                    }

                    if (!entry.commentedOut)
                    {
                        history.Add(input);
                    }
                }
                else
                {
                    output.AppendLine("Execution error: " + entry.errorMessage);
                    var axe = entry.axe;
                    if (axe != null)
                    {
                        output.AppendLine("Command execution exception: " + axe.title);
                        output.AppendLine("Message: " + axe.Message);
                        output.AppendLine("Source: " + axe.Source);
                        output.AppendLine("File: " + axe.callInfo.Filepath);
                        output.AppendLine("Method: " + axe.callInfo.methodName);
                        output.AppendDataFields(axe.info);

                        if (aceTerminalInput.askAnyKeyInTime("Press ESCAPE (or wait timeout) to throw the exception --- any other key to continue execution", ConsoleKey.Escape, 15, true, 15) == ConsoleKey.Escape)
                        {
                            throw axe;
                        }
                    }
                }
            }
        }