Ejemplo n.º 1
0
        public bool Starter(string stdin)
        {
            Formatters format = new Formatters();
            Executor   execute = new Executor();
            string     cmd, cmdLoc;

            //Converting command to lowercase
            if (format.Break(stdin) != null)
            {
                cmd = format.Break(stdin).ToLower();
            }
            else
            {
                return(false);
            }

            if (FindInternal(cmd) && this.PRIORITIZE_BUILTIN_SHELL)
            {
                execute.exec_in(cmd, format.getArguments());
                return(true);
            }

            cmdLoc = Find(cmd);

            if (!string.IsNullOrEmpty(cmdLoc))
            {
                execute.Execute(cmdLoc, format.getArguments());
            }
            else
            {
                execute.exec_in(cmd, format.getArguments());
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Command Execution bootstrap.
        /// </summary>
        /// <param name="stdin">Takes the user's input as parameter.</param>
        /// <param name="cmd">Holds only to command program to executes.</param>
        /// <param name="cmdLoc">Holds the program to executes path location.</param>
        /// <returns></returns>
        public bool Starter(string stdin)
        {
            Formatters format  = new Formatters();
            Executor   execute = new Executor();

            string cmd, cmdLoc;

            //Converting command to lowercase
            if (format.Break(stdin) != null)
            {
                cmd = format.Break(stdin).ToLower();
            }
            else
            {
                return(false);
            }

            //If built-in command is to be prioritize, searches if the command exists then executes it.
            if (FindInternal(cmd) && this.PRIORITIZE_BUILTIN_SHELL)
            {
                execute.exec_in(cmd, format.getArguments());
                return(true);
            }

            cmdLoc = Find(cmd); //loads the path of the command to executes.

            if (!string.IsNullOrEmpty(cmdLoc))
            {
                execute.Execute(cmdLoc, format.getArguments());
            }
            else
            {
                execute.exec_in(cmd, format.getArguments());
            }

            return(true);
        }