Esempio n. 1
0
        /// <summary>
        /// Writes the completion stats for the given build stages.
        /// </summary>
        protected virtual void WriteStageStats(ExecutionPlan plan, Dictionary <char, BuildStage> stageInfo)
        {
            int firstColumn   = 8;
            int secondColumn  = Math.Max(stageInfo.Max(x => x.Value.Name.Length) + 4, 20);
            int thirdColumn   = 10;
            int fourthColumn  = 10;
            int totalColWidth = firstColumn + secondColumn + thirdColumn + fourthColumn;


            // FX Creates a writable line
            string CreateLine(char letter, string name, string status, string duration) =>
            "( " + letter + " )  " +
            name.PadRight(secondColumn, paddingChar: ' ') +
            status.PadRight(thirdColumn, paddingChar: ' ') +
            duration.PadLeft(fourthColumn, paddingChar: ' ');
Esempio n. 2
0
        /// <summary>
        /// Writes End of slugBuilder Summary info.
        /// </summary>
        internal virtual void WriteSummary(ExecutionPlan plan, bool isInteractive, CISession ciSession)
        {
            Console.WriteLine();
            Misc.WriteFinalHeader(plan.PlanStatus, ciSession);

            // Build dictionary of each Build Stage in order, assigning a letter to each stage.  The letter will allow user to see detailed info
            // about the stage.
            Dictionary <char, BuildStage> stageInfo = new Dictionary <char, BuildStage>();
            char letter = 'A';

            foreach (BuildStage buildStage in plan.Plan)
            {
                stageInfo.Add(letter, buildStage);
                letter++;
            }


            bool continueLooping = true;

            while (continueLooping)
            {
                // Print info for non interactive sessions
                if (!isInteractive)
                {
                    if (Logger.OutputSink.SevereMessages.Count > 0)
                    {
                        CISession.OutputSink.WriteNormal("");
                        WriteSevereMessages();
                        WriteStageStats(plan, stageInfo);
                    }
                }
                else
                {
                    CISession.OutputSink.WriteNormal("");
                    WriteStageStats(plan, stageInfo);
                    CISession.OutputSink.WriteNormal("");
                }


                // Write Version info if successful build
                if (plan.WasSuccessful)
                {
                    CISession.OutputSink.WriteSuccess($"Build succeeded on {DateTime.Now.ToString(CultureInfo.CurrentCulture)}");
                    Console.WriteLine();
                    Console.WriteLine("Version Built was: ", Color.Yellow);
                    Console.WriteLine("    Semantic Version:   " + ciSession.VersionInfo.SemVersionAsString, Color.Yellow);
                    Console.WriteLine("    Assembly Version:   " + ciSession.VersionInfo.AssemblyVersion, Color.Yellow);
                    Console.WriteLine("    File Version:       " + ciSession.VersionInfo.FileVersion, Color.Yellow);
                    Console.WriteLine("    Info Version:       " + ciSession.VersionInfo.InformationalVersion, Color.Yellow);
                }
                else
                {
                    CISession.OutputSink.WriteError($"Build failed on {DateTime.Now.ToString(CultureInfo.CurrentCulture)}");
                }


                // Exit if non-interactive as rest is user prompting and responding
                if (!isInteractive)
                {
                    return;
                }

                Console.WriteLine("Press (x) to exit, (1) to display git history  (9) to view detailed error information  OR");
                Console.WriteLine("  Press letter from above build stage to see detailed output of that build stage.");
                ConsoleKeyInfo keyInfo = Console.ReadKey();
                if (keyInfo.Key == ConsoleKey.X)
                {
                    return;
                }

                // Detailed error info
                if (keyInfo.Key == ConsoleKey.D9)
                {
                    CISession.OutputSink.WriteNormal("");
                    WriteSevereMessages();
                }

                // Git history
                if (keyInfo.Key == ConsoleKey.D1)
                {
                    ciSession.GitProcessor.PrintGitHistory();
                    Console.WriteLine("Press [space] key to return to menu", Color.Yellow);
                    while (Console.ReadKey().Key != ConsoleKey.Spacebar)
                    {
                    }
                }

                // Check to see if letter is in StageInfo Dictionary.
                char keyPress = keyInfo.KeyChar;
                if (keyPress > 96)
                {
                    keyPress = (char)(keyPress - 32);
                }


                // Display detailed info about a specific stage...
                if (stageInfo.ContainsKey(keyPress))
                {
                    // Display detailed info
                    BuildStage stage = stageInfo [keyPress];

                    Console.WriteLine();
                    Misc.WriteSubHeader(stage.Name, new List <string>()
                    {
                        "Detailed Output"
                    });
                    Color lineColor = Color.WhiteSmoke;
                    foreach (LineOutColored output in stage.StageOutput)
                    {
                        output.WriteToConsole();
                    }

                    Console.WriteLine();
                    Console.WriteLine("Press [space] key to return to menu", Color.Yellow);
                    while (Console.ReadKey().Key != ConsoleKey.Spacebar)
                    {
                    }
                }
            }
        }