Exemplo n.º 1
0
        public int ExecuteCommand(string commandSelectedByUser, List <string> parametersSelectedByUser)
        {
            CompleteCommand commandToRun = BuildCommand(commandSelectedByUser, parametersSelectedByUser);

            if (commandToRun != null)
            {
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine("Running: {0} {1}", commandToRun.ToolCommand, commandToRun.ParametersCommand);
                Console.ResetColor();

                int result = RunProcess.ExecuteProcess(commandToRun.ToolCommand, commandToRun.ParametersCommand);
                if (result == 0)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Build Succeeded.");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Build Failed.");
                }
                Console.ResetColor();

                return(result);
            }
            return(1);
        }
Exemplo n.º 2
0
        public int ExecuteCommand(string commandSelectedByUser, List <string> parametersSelectedByUser)
        {
            ParseRunToolSettings(commandSelectedByUser);
            string runQuietValue;
            bool   runQuiet = false;

            if (ToolSettings.TryGetValue(RunQuietReservedKeyword, out runQuietValue))
            {
                runQuiet = runQuietValue.Equals("true", StringComparison.OrdinalIgnoreCase);
            }
            string whatIfValue;
            bool   whatIf = false;

            if (ToolSettings.TryGetValue(WhatIfReservedKeyword, out whatIfValue))
            {
                if (string.IsNullOrEmpty(whatIfValue))
                {
                    ToolSettings.TryGetValue(DryRunReservedKeyword, out whatIfValue);
                }
                whatIf = whatIfValue.Equals("true", StringComparison.OrdinalIgnoreCase);
            }

            CompleteCommand commandToRun = BuildCommand(commandSelectedByUser, parametersSelectedByUser);

            if (commandToRun != null)
            {
                int result = 0;

                if (whatIf)
                {
                    PrintColorMessage(ConsoleColor.Yellow, "Showing command, would execute:");
                    PrintColorMessage(ConsoleColor.Yellow, $"\n\n{commandToRun.ToolCommand} {commandToRun.ParametersCommand}\n");
                }
                else
                {
                    if (!runQuiet)
                    {
                        PrintColorMessage(ConsoleColor.DarkYellow, $"Running: {commandToRun.ToolCommand} {commandToRun.ParametersCommand}");
                    }
                    result = RunProcess.ExecuteProcess(commandToRun.ToolCommand, commandToRun.ParametersCommand);
                    if (!runQuiet)
                    {
                        if (result == 0)
                        {
                            PrintColorMessage(ConsoleColor.Green, "Command execution succeeded.");
                        }
                        else
                        {
                            PrintColorMessage(ConsoleColor.Red, "Command execution failed with exit code {0}.", result);
                        }
                    }
                }
                return(result);
            }
            return(1);
        }
Exemplo n.º 3
0
        public int ExecuteCommand(string commandSelectedByUser, List <string> parametersSelectedByUser)
        {
            ParseRunToolSettings(commandSelectedByUser);
            string runQuietValue;
            bool   runQuiet = false;

            if (ToolSettings.TryGetValue(RunQuietReservedKeyword, out runQuietValue))
            {
                runQuiet = runQuietValue.Equals("true", StringComparison.OrdinalIgnoreCase);
            }
            CompleteCommand commandToRun = BuildCommand(commandSelectedByUser, parametersSelectedByUser);

            if (commandToRun != null)
            {
                if (!runQuiet)
                {
                    PrintColorMessage(ConsoleColor.DarkYellow, "Running: {0} {1}", commandToRun.ToolCommand, commandToRun.ParametersCommand);
                }

                int result = RunProcess.ExecuteProcess(commandToRun.ToolCommand, commandToRun.ParametersCommand);
                if (!runQuiet)
                {
                    if (result == 0)
                    {
                        PrintColorMessage(ConsoleColor.Green, "Command execution succeeded.");
                    }
                    else
                    {
                        PrintColorMessage(ConsoleColor.Red, "Command execution failed with exit code {0}.", result);
                    }
                }

                return(result);
            }
            return(1);
        }