static int Main(string[] args)
        {
            var console           = new ConsoleAbstraction();
            var logic             = ShowCommitsForBuildCoordinator.Create(console);
            var buildNumberGetter = new BuildNumberGetter(console, args);
            var failureFeedback   = new FailureFeedback(console);

            try
            {
                var buildNumber = buildNumberGetter.GetBuildNumberFromArgsOrUserInput();
                return(logic.ShowCommitsForBuild(buildNumber)
                    ? (int)ProgramReturnValues.Success
                    : (int)ProgramReturnValues.NoBuild);
            }
            catch (WebException ex)
            {
                failureFeedback.PrintFatalWebFailure(ex);
                console.Pause();
                return((int)ProgramReturnValues.WebException);
            }
            catch (Exception ex)
            {
                failureFeedback.PrintFatalFailure(ex);
                console.Pause();
                return((int)ProgramReturnValues.GeneralException);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Main entry point.
        /// </summary>
        /// <param name="args">Arguments for application.</param>
        /// <returns>Exit code.</returns>
        public static int Main(
            string[] args)
        {
            try
            {
                WriteAsciiArt(Console.WriteLine);

                var consoleAbstraction = new ConsoleAbstraction();

                // ConsoleAbstraction must derive from ConsoleAbstractionBase which is provided in the Bootstrapper recipes, it contains the implementation of this method.
                consoleAbstraction.PerformEntryPointPreChecks();

                // Need to register the exception types to the static context.
                ConsoleAbstractionBase.UpdateTypeRepresentationsOfExceptionsToOmitStackTraceFrom(consoleAbstraction.ExceptionTypeRepresentationsToOnlyPrintMessage);

                /*---------------------------------------------------------------------------*
                * This is just a pass through to the CLAP implementation of the harness,    *
                * it will parse the command line arguments and provide multiple entry       *
                * points as configured.  It is easiest to derive from the abstract class    *
                * 'ConsoleAbstractionBase' as 'ExampleConsoleAbstraction' does which        *
                * provides an example of the minimum amount of work to get started.  It is  *
                * installed as a recipe for easy reference and covers help, errors, etc.    *
                *---------------------------------------------------------------------------*
                * For an example of config files you can install the package                *
                * 'Naos.Recipes.Console.ExampleConfig' which has examples of the directory  *
                * structure, 'LogProcessorSettings' settings for console and file, as well  *
                * as an App.Config it not using the environment name as a parameter.        *
                *---------------------------------------------------------------------------*
                * Must update the code below to use your custom abstraction class.          *
                *---------------------------------------------------------------------------*/
                var exitCode = Parser.Run <ConsoleAbstraction>(args);
                return(exitCode);
            }
            catch (Exception ex)
            {
                /*---------------------------------------------------------------------------*
                * This should never be reached but is here as a last ditch effort to ensure *
                * errors are not lost.                                                      *
                *---------------------------------------------------------------------------*/
                Console.WriteLine(string.Empty);
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.WriteLine(string.Empty);
                Log.Write(ex);

                return(1);
            }
        }