예제 #1
0
        public int Invoke()
        {
            // Remove when we incorporate into real help
            if (Help2)
            {
                var rootCommandSource = CommandSource.Create <DotnetCommand>() as DotnetCommandCommandSource;
                var commandSource     = rootCommandSource?.NewCommandCommand;
                return(DisplayListHelp(UxLevel, RenderTo, RenderToFileName, commandSource, true));
            }
            var commonTemplates = "console, classlib";
            var data            = TemplateData.SampleData; // get real data here

            var selector = new Selector();

            selector.AddRange(data.Select(template => new SelectorItem(template.ShortName,
                                                                       template.TemplateName,
                                                                       commonTemplates.Contains(template.ShortName))));
            selector.Sorted = true;
            var shortName = Cli.GetFromPrompt(selector, RenderTo, UxLevel);

            Console.WriteLine(string.IsNullOrWhiteSpace(shortName)
                                ? "Enter a template name or a command"
                                : $"Run {shortName}");
            return(0);
        }