public static string GetOutput(string program, string arguments, bool ignoreExitCode = false)
        {
            var exe      = new InternalExe(program, arguments);
            var sb       = new StringBuilder();
            var exitCode = exe.Run(o => sb.AppendLine(o?.Trim()), e => ColoredConsole.Error.WriteLine(e.Red()));

            if (!ignoreExitCode && exitCode != 0)
            {
                throw new Exception($"{program} exit code == {exitCode}");
            }

            return(sb.ToString().Trim(new[] { ' ', '\r', '\n' }));
        }
예제 #2
0
        public static void Run(string program, string arguments, bool streamOutput = true)
        {
            var exe = new InternalExe(program, arguments, streamOutput);

            ColoredConsole.WriteLine($"> {program} {arguments}".Green());

            var exitcode = exe.Run(l => ColoredConsole.Out.WriteLine(l.DarkGray()), e => ColoredConsole.Error.WriteLine(e.Red()));

            if (exitcode != 0)
            {
                throw new Exception($"{program} Exit Code == {exitcode}");
            }
        }