Esempio n. 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}");
            }
        }
Esempio n. 2
0
        private void WriteListOfTasks([NotNull] IBuildContext context)
        {
            var build = context.CompositionService.Resolve<Build>();

            foreach (var task in build.Tasks.OrderBy(t => t.TaskName))
            {
                var helpWriter = new HelpWriter();
                task.WriteHelp(helpWriter);

                var summary = helpWriter.GetSummary();
                if (string.IsNullOrEmpty(summary))
                {
                    continue;
                }

                context.Trace.WriteLine($"{task.TaskName} - {summary}");
            }

            var scripts = new List<string>();
            var scriptDirectory = Path.Combine(context.ToolsDirectory, "files\\scripts");
            if (context.FileSystem.DirectoryExists(scriptDirectory))
            {
                scripts = context.FileSystem.GetFiles(scriptDirectory).Select(Path.GetFileName).ToList();
            }

            scriptDirectory = Path.Combine(context.ProjectDirectory, "sitecore.project\\scripts");
            if (context.FileSystem.DirectoryExists(scriptDirectory))
            {
                scripts.AddRange(context.FileSystem.GetFiles(scriptDirectory).Select(Path.GetFileName));
            }

            if (!scripts.Any())
            {
                return;
            }

            context.Trace.WriteLine("");
            context.Trace.WriteLine("SCRIPTS:");

            foreach (var script in scripts.OrderBy(t => t))
            {
                context.Trace.WriteLine(script);
            }
        }