public bool RunCommand(string userInput) { bool legalInput = true; string[] inputParts = userInput.Split(); CliShellCommand wanted_command = this._commands.Where(c => c.Keyword == inputParts[0]).FirstOrDefault(); if (wanted_command != null) { // Run command. string commandData = userInput.Substring(userInput.IndexOf(" ") + 1); wanted_command.Action(commandData); } else { Console.WriteLine("Illegal Input."); legalInput = false; } return(legalInput); }
public void AddCommand(CliShellCommand cliShellCommand) { this._commands.Add(cliShellCommand); }