private CommandResultType ProcessArguments(string[] arguments) { ConsoleParameter parameter = ParseParameter(arguments); if (!_commands.ContainsKey(parameter.Key)) { Logger.Error( $"Command: '{parameter.Key}' not available. Type `help' for a list of available commands."); return(CommandResultType.Continue); } IConsoleCommand consoleCommand = _commands[parameter.Key]; if (consoleCommand != _switchCommand) { _switchCommand.Handle(parameter); } return(consoleCommand.Handle(parameter)); }
public static bool Handle(string text) { IConsoleCommand command = _commands.Where(cmd => cmd.Name.ToLower().Equals(text.Split(' ')[0])).FirstOrDefault(); if (command == null) { return(false); } string[] parameters; if (text.Length <= 1 + command.Name.Length) { parameters = new string[0]; } else { parameters = text.Substring(1 + command.Name.Length).Split(' '); } return(command.Handle(parameters)); }
/// <summary>Handle a console command.</summary> /// <param name="command">The command to invoke.</param> /// <param name="commandName">The command name specified by the user.</param> /// <param name="args">The command arguments.</param> private void HandleCommand(IConsoleCommand command, string commandName, string[] args) { ArgumentParser argParser = new ArgumentParser(commandName, args, this.Monitor); command.Handle(this.Monitor, commandName, argParser); }