/// <summary>
 /// Adds new <seealso cref="ConsoleModule"/> to console.
 /// </summary>
 /// <param name="moduleToAdd"></param>
 public void AddModule(ConsoleModule moduleToAdd) => modules.Add(moduleToAdd);
        /// <summary>
        /// Executes given command.
        /// </summary>
        /// <param name="c"></param>
        public void ExecuteCommand(string c)
        {
            if (string.IsNullOrEmpty(c))
            {
                return;
            }

            Print(c);

            if (autoSaveLogs)
            {
                SaveLogs();
            }

            lastCommands.Add(c.Trim());
            lastCommandIndex = lastCommands.Count;

            List <string> words = new List <string>();

            words.AddRange(c.Trim().Split(' '));

            string command = words[0];

            words.RemoveAt(0);

            inputField.text = "";
            inputField.ActivateInputField();

            ConsoleModule module = null;

            foreach (ConsoleModule m in modules)
            {
                if (m.CompareCommand(command))
                {
                    module = m;
                    break;
                }
            }

            if (module == null)
            {
                string alias = "";

                for (int i = 0; i < aliases.Count; i++)
                {
                    if (command == aliases[i].alias)
                    {
                        alias = aliases[i].associatedCommand;
                        break;
                    }
                }

                if (alias != "")
                {
                    foreach (ConsoleModule m in modules)
                    {
                        if (m.CompareCommand(alias))
                        {
                            module = m;
                            break;
                        }
                    }
                }
            }

            if (module == null)
            {
                PrintError(CommandResults.WRONG_COMMAND_MESS);
                return;
            }

            if (module.arguments >= 0)
            {
                if (words.Count != module.arguments)
                {
                    PrintError(CommandResults.WRONG_ARGS_MESS);
                    return;
                }
            }

            string executionResult   = "";
            bool   exectuedCorrectly = module.ExecuteCommand(this, ref executionResult, words.ToArray());

            if (!exectuedCorrectly)
            {
                PrintError(executionResult);
                return;
            }
            else if (exectuedCorrectly && !string.IsNullOrEmpty(executionResult))
            {
                Print(executionResult);
                return;
            }
        }