Exemplo n.º 1
0
        public async static Task <int> Main(string[] args2)
        {
            RunnerArgs args = RunnerArgs.FromCommandLine(args2);

            ProgramRunner runner = new ProgramRunner(args);

            try
            {
                await runner.ExecuteAsync();
            }
            catch (ToolException ex)
            {
                if (!string.IsNullOrWhiteSpace(ex.StdOut))
                {
                    WriteLine(ex.StdOut, ConsoleColor.Red);
                }

                if (!string.IsNullOrWhiteSpace(ex.StdErr))
                {
                    WriteLine(ex.StdErr, ConsoleColor.Red);
                }

                return(-1);
            }
            catch (Exception ex)
            {
                WriteLine(ex.Message, ConsoleColor.Red);

                return(-1);
            }

            return(0);
        }
Exemplo n.º 2
0
        public async static Task <int> Main(string[] args)
        {
            RunnerArgs runnerArgs;

            try
            {
                runnerArgs = RunnerArgs.FromCommandLine(args);
            }
            catch (FileNotFoundException ex)
            {
                WriteHeader();
                WriteLine();
                WriteLine($"Could not expand '@{Path.GetFileName(ex.FileName)}'. File not found.", ConsoleColor.Red);

                return(-1);
            }
            catch (Exception ex)
            {
                WriteHeader();
                WriteLine();
                WriteLine(ex.Message, ConsoleColor.Red);

                return(-1);
            }

            try
            {
                await new ProgramRunner(runnerArgs).ExecuteAsync();
            }
            catch (ToolException ex)
            {
                if (!string.IsNullOrWhiteSpace(ex.StdOut))
                {
                    WriteLine(ex.StdOut, ConsoleColor.Red);
                }

                if (!string.IsNullOrWhiteSpace(ex.StdErr))
                {
                    WriteLine(ex.StdErr, ConsoleColor.Red);
                }

                return(-1);
            }
            catch (Exception ex)
            {
                bool isVerbose = runnerArgs?.Verbose ?? false;

                WriteLine(isVerbose ? ex.ToString() : ex.Message, ConsoleColor.Red);

                return(-1);
            }

            return(0);
        }