private static void Fail(string message, IReadOnlyCollection <ExecutableTarget> executableTargets)
 {
     ControlFlow.Fail(new StringBuilder()
                      .AppendLine(message)
                      .AppendLine()
                      .AppendLine(HelpTextService.GetTargetsText(executableTargets)).ToString());
 }
Exemple #2
0
        public void Execute(NukeBuild build)
        {
            if (NukeBuild.Help)
            {
                Logger.Normal(HelpTextService.GetTargetsText(build.ExecutableTargets));
                Logger.Normal(HelpTextService.GetParametersText(build));
            }

            if (NukeBuild.Plan)
            {
                ExecutionPlanHtmlService.ShowPlan(build.ExecutableTargets);
            }

            if (NukeBuild.Help || NukeBuild.Plan)
            {
                Environment.Exit(exitCode: 0);
            }
        }
Exemple #3
0
        private static void HandleEarlyExits <T>(T build)
            where T : NukeBuild
        {
            if (build.Help)
            {
                Logger.Log(HelpTextService.GetTargetsText(build));
                Logger.Log(HelpTextService.GetParametersText(build));
            }

            if (build.Graph)
            {
                GraphService.ShowGraph(build);
            }

            if (build.Help || build.Graph)
            {
                Environment.Exit(exitCode: 0);
            }
        }
Exemple #4
0
        public void OnAfterLogo(
            NukeBuild build,
            IReadOnlyCollection <ExecutableTarget> executableTargets,
            IReadOnlyCollection <ExecutableTarget> executionPlan)
        {
            if (NukeBuild.Help || executionPlan.Count == 0)
            {
                Logger.Normal(HelpTextService.GetTargetsText(build.ExecutableTargets));
                Logger.Normal(HelpTextService.GetParametersText(build));
            }

            if (NukeBuild.Plan)
            {
                ExecutionPlanHtmlService.ShowPlan(build.ExecutableTargets);
            }

            if (NukeBuild.Help || executionPlan.Count == 0 || NukeBuild.Plan)
            {
                Environment.Exit(exitCode: 0);
            }
        }
        public void OnBuildInitialized(
            NukeBuild build,
            IReadOnlyCollection <ExecutableTarget> executableTargets,
            IReadOnlyCollection <ExecutableTarget> executionPlan)
        {
            if (build.Help || executionPlan.Count == 0)
            {
                Host.Debug(HelpTextService.GetTargetsText(build.ExecutableTargets));
                Host.Debug(HelpTextService.GetParametersText(build));
            }

            if (build.Plan)
            {
                ExecutionPlanHtmlService.ShowPlan(build.ExecutableTargets);
            }

            if (build.Help || executionPlan.Count == 0 || build.Plan)
            {
                Environment.Exit(exitCode: 0);
            }
        }
        private static TargetDefinition GetDefinition(
            string targetName,
            NukeBuild build)
        {
            if (targetName.EqualsOrdinalIgnoreCase(BuildExecutor.DefaultTarget))
            {
                return(build.TargetDefinitions.Single(x => x.IsDefault));
            }

            var targetDefinition = build.TargetDefinitions.SingleOrDefault(x => x.Name.EqualsOrdinalIgnoreCase(targetName));

            if (targetDefinition == null)
            {
                var stringBuilder = new StringBuilder()
                                    .AppendLine($"Target with name '{targetName}' is not available.")
                                    .AppendLine()
                                    .AppendLine(HelpTextService.GetTargetsText(build));

                ControlFlow.Fail(stringBuilder.ToString());
            }

            return(targetDefinition);
        }