public void ListCommands(string[] arguments) { foreach (string key in _commands.Keys) { cCommand com = _commands[key]; _lines.Add("-> '" + key + "' - " + com._help); } }
public void addSilentCmd(cCommand cmd) { clearRedo(); pQueue.AddLast(cmd); pLastAction = pQueue.Last; isPossible(); }
public void HelpOnCommand(string[] arguments) { if (arguments.Length <= 0) { _lines.Add("USAGE: 'help [command]'"); return; } if (!_commands.ContainsKey(arguments[0])) { _lines.Add("HELP CANNOT FIND COMMAND '" + arguments[0] + "'"); return; } cCommand com = _commands[arguments[0]]; _lines.Add("HELP: '" + arguments[0] + "' - " + com._help); }
public void AddCommand(string command, string help, ConsoleCommand func) { command = command.ToLower(); if (!_commands.ContainsKey(command)) { cCommand com = new cCommand(); com._help = help; com._func = func; _commands.Add(command, com); } else { Console.WriteLine("COMMAND " + command + "ALREADY EXISTS!"); } }
public async Task <cCommandResult> ExecuteAsync(cMethodControl pMC, sCommandDetails pCommandDetails, cTrace.cContext pParentContext) { var lContext = pParentContext.NewMethod(nameof(cCommandPipeline), nameof(ExecuteAsync), pMC, pCommandDetails); if (mDisposed) { pCommandDetails.Disposables?.Dispose(); throw new ObjectDisposedException(nameof(cCommandPipeline)); } if (mState < eState.connected) { pCommandDetails.Disposables?.Dispose(); throw new InvalidOperationException(kInvalidOperationExceptionMessage.NotConnected); } cCommand lCommand; lock (mPipelineLock) { if (mState == eState.stopped) { pCommandDetails.Disposables.Dispose(); throw mBackgroundTaskException; } lCommand = new cCommand(pCommandDetails); mQueuedCommands.Enqueue(lCommand); mBackgroundReleaser.Release(lContext); } try { return(await lCommand.WaitAsync(pMC, lContext).ConfigureAwait(false)); } finally { lock (mPipelineLock) { if (lCommand.State == eCommandState.queued) { lCommand.SetComplete(lContext); } } } }
private void processInput(string str) { char[] space = new char[] { ' ' }; string[] words = str.Split(space); if (words == null || words.Length < 1) { _lines.Add("UNKNOWN COMMAND '" + str + "'"); return; } if (!_commands.ContainsKey(words[0])) { _lines.Add("UNKNOWN COMMAND '" + str + "'"); return; } if (_commands.ContainsKey(words[0])) { string[] args = new string[words.Length - 1]; for (int i = 1; i < words.Length; i++) { args[i - 1] = words[i]; } cCommand com = _commands[words[0]]; com._func(args); _lines.Add("COMMAND EXECUTED '" + words[0] + "'"); } }
public void addCmd(cCommand cmd) { addSilentCmd(cmd); pLastAction.Value.doCmd(); }
private bool ZBackgroundTaskProcessCommandCompletion(cBytesCursor pCursor, cCommand pCommand, cTrace.cContext pParentContext) { var lContext = pParentContext.NewMethod(nameof(cCommandPipeline), nameof(ZBackgroundTaskProcessCommandCompletion), pCommand); var lResult = ZProcessCommandCompletionResponse(pCursor, pCommand.Tag, pCommand.IsAuthentication, pCommand.Hook, lContext); if (lResult == null) { return(false); } if (pCommand.UIDValidity != null && pCommand.UIDValidity != mMailboxCache?.SelectedMailboxDetails?.MessageCache.UIDValidity) { pCommand.SetException(new cUIDValidityException(lContext), lContext); } else { pCommand.SetResult(lResult, lContext); } return(true); }