Exemple #1
0
        internal static TemplateResult FromParseResult(TemplateCommand templateCommand, ParseResult parseResult)
        {
            TemplateResult result = new TemplateResult(templateCommand, parseResult);

            result.IsLanguageMatch = templateCommand.LanguageOption == null || !parseResult.HasErrorFor(templateCommand.LanguageOption);
            result.IsTypeMatch     = templateCommand.TypeOption == null || !parseResult.HasErrorFor(templateCommand.TypeOption);
            result.IsBaselineMatch = templateCommand.BaselineOption == null || !parseResult.HasErrorFor(templateCommand.BaselineOption);
            foreach (var option in templateCommand.TemplateOptions)
            {
                if (parseResult.HasErrorFor(option.Value.Option))
                {
                    result._parametersInfo.Add(InvalidTemplateOptionResult.FromParseResult(option.Value, parseResult));
                }
                else
                {
                    if (TemplateOptionResult.FromParseResult(option.Value, parseResult) is TemplateOptionResult {
                    } res)
                    {
                        result._parametersInfo.Add(res);
                    }
                }
            }
            foreach (var unmatchedToken in parseResult.UnmatchedTokens)
            {
                result._parametersInfo.Add(new InvalidTemplateOptionResult(
                                               null,
                                               InvalidTemplateOptionResult.Kind.InvalidName,
                                               inputFormat: unmatchedToken,
                                               specifiedValue: null,
                                               errorMessage: null));
            }
            return(result);
        }
Exemple #2
0
        internal static List <TemplateResult> CollectTemplateMatchInfo(InstantiateCommandArgs args, IEngineEnvironmentSettings environmentSettings, TemplatePackageManager templatePackageManager, TemplateGroup templateGroup)
        {
            List <TemplateResult> matchInfos = new List <TemplateResult>();

            foreach (CliTemplateInfo template in templateGroup.Templates)
            {
                if (ReparseForTemplate(args, environmentSettings, templatePackageManager, templateGroup, template)
                    is (TemplateCommand command, ParseResult parseResult))
                {
                    matchInfos.Add(TemplateResult.FromParseResult(command, parseResult));
                }
            }
            return(matchInfos);
        }