public void InputLoop()
        {
            string command = "";

            while (command != "exit")
            {
                command = PromptResponse("command >").Trim();
                SplicedContainer commandSplicedFromArgs = Utils.SplicedContainerForIndexOfAray(command.Split(' '), 0);

                string[] arguments = commandSplicedFromArgs.RemainingArray;
                command = commandSplicedFromArgs.Spliced;

                bool found = false;
                foreach (ICommandPlugin plugin in PluginRepository.Commands)
                {
                    if (plugin.CanHandle(command))
                    {
                        string[] results = plugin.Handle(arguments);
                        UserInteraction.ShowMessages(results);
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    ShowMessage($"There is currently no plugin to handle the command {command}\n\r");
                }
            }
        }
示例#2
0
        public static SplicedContainer SplicedContainerForIndexOfAray(string[] args, int index)
        {
            SplicedContainer splicedContainer = new SplicedContainer();

            splicedContainer.RemainingArray = new string[args.Length - 1];
            for (int i = 0; i < args.Length; i++)
            {
                if (i == index)
                {
                    splicedContainer.Spliced = args[i];
                }
                else
                {
                    splicedContainer.RemainingArray[i > index ? i - 1 : i] = args[i];
                }
            }
            return(splicedContainer);
        }