예제 #1
0
        private void WriteCommandHelp([NotNull] IBuildContext context, [NotNull] string taskName)
        {
            var build = context.CompositionService.Resolve<Build>();
            var task = build.Tasks.FirstOrDefault(t => string.Equals(t.TaskName, taskName, StringComparison.OrdinalIgnoreCase));
            if (task == null)
            {
                context.Trace.WriteLine($"Task not found: {taskName}");
                context.Trace.WriteLine(string.Empty);
                WriteListOfTasks(context);
                return;
            }

            var helpWriter = new HelpWriter();
            task.WriteHelp(helpWriter);

            context.Trace.WriteLine("TASK:");
            context.Trace.WriteLine($"  {task.TaskName}");
            context.Trace.WriteLine(string.Empty);

            context.Trace.WriteLine("SUMMARY:");
            context.Trace.WriteLine($"{helpWriter.GetSummary()}");
            context.Trace.WriteLine(string.Empty);

            context.Trace.WriteLine("PARAMETERS:");
            context.Trace.WriteLine($"{helpWriter.GetParameters()}");
            context.Trace.WriteLine(string.Empty);

            context.Trace.WriteLine("REMARKS:");
            context.Trace.WriteLine($"{helpWriter.GetRemarks()}");
            context.Trace.WriteLine(string.Empty);

            context.Trace.WriteLine("EXAMPLES:");
            var examples = helpWriter.GetExamples();
            if (!string.IsNullOrEmpty(examples))
            {
                context.Trace.WriteLine(examples);
            }
            else
            {
                context.Trace.WriteLine($"  scc {task.TaskName}");
            }
        }