/// <summary> /// Executes the specified console. /// </summary> /// <param name="console">The console.</param> /// <param name="__parent">The parent.</param> /// <param name="delay">The delay.</param> /// <param name="skipLines">Number of lines to skip</param> public void Execute(aceCommandConsole console, aceConsoleScript __parent, Int32 delay = 1, Int32 skipLines = -1) { parent = __parent; executionStart = DateTime.Now; currentLine = 0; foreach (String line in this) { if (currentLine > skipLines) { if (line.isNullOrEmptyString() || line == Environment.NewLine) { // skipping empty line } else { if (scriptExecutionAborted) { scriptExecutionAborted = false; break; } switch (imbACECoreConfig.settings.doShowScriptLines) { case scriptLineShowMode.none: break; case scriptLineShowMode.undefined: break; case scriptLineShowMode.onlyCodeLine: console.output.AppendLine(line); break; case scriptLineShowMode.fullPrefixAndCodeLine: console.output.log("Script [" + currentLine.ToString("D3") + "]: " + line); break; case scriptLineShowMode.codeNumberAndCodeLine: console.output.AppendLine("[" + currentLine.ToString("D3") + "] _" + line + "_"); break; } console.executeCommand(line); Thread.Sleep(delay); } } currentLine++; } executionFinish = DateTime.Now; }
protected void validate() { if (hasCommand) { IAceOperationSetExecutor executor = console; if (hasPrefix) { String __prefix = prefix.toCsvInLine(COMMANDPREFIX_SEPARATOR); executor = console.imbGetPropertySafe(__prefix, console) as IAceOperationSetExecutor; if (executor == null) { if (console is aceCommandConsole) { aceCommandConsole aceConsole = console as aceCommandConsole; __prefix = __prefix.removeStartsWith(aceConsole.commandSetTree.name + "."); executor = console.imbGetPropertySafe(__prefix, console) as IAceOperationSetExecutor; if (executor == null) { var coms = aceConsole.commandSetTree.GetCommands(__prefix); if (coms.Any()) { var com = coms.FirstOrDefault(x => (x.name == command || x.menuMeta.aliasList.Contains(command))); if (com != null) { commandTreeDescription node = com.parent as commandTreeDescription; if (node != null) { switch (node.nodeLevel) { case commandTreeNodeLevel.group: break; case commandTreeNodeLevel.plugin: break; default: break; } } } else { isSyntaxError = true; errorMessage = "Command not found at [" + prefix.toCsvInLine(COMMANDPREFIX_SEPARATOR) + "][" + console.consoleTitle + "]. Suggestions:"; foreach (var c in coms) { errorMessage = errorMessage.addLine(c.path); } } } } else { } } } } if (isSyntaxError || (executor == null)) { isSyntaxError = true; errorMessage = "Unknown property prefix [" + prefix.toCsvInLine(COMMANDPREFIX_SEPARATOR) + "] at [" + console.consoleTitle + "]."; } else { operation = executor.commands.getItem(command, -1, false, true); } if (operation == null) { isSyntaxError = true; errorMessage = "Unknown command [" + command + "] for console [" + console.consoleTitle + "]. Type 'help' to show list of commands."; } else { if (operation.metaObject is aceOperationArgs) { marg = operation.metaObject as aceOperationArgs; carg = marg.Clone() as aceOperationArgs; String error = ""; switch (format) { case commandLineFormat.explicitFormat: error = carg.paramSet.setValues(parameterName, parameterValue); break; case commandLineFormat.implicitFormat: error = carg.paramSet.setValues(parameterValue); break; case commandLineFormat.onlyCommand: break; } } else { isSyntaxError = true; errorMessage = "Command [" + command + "] for console [" + console.consoleTitle + "] not supported. Type 'help' to show list of commands."; } } } }