예제 #1
0
 internal static void WriteListPatternsCommand(ListPatternsCommandOptions options)
 {
     WriteOption("char", options.Value);
     WriteOption("char group", options.InCharGroup);
     WriteFilter("filter", options.Filter);
     WriteOption("regex options", options.RegexOptions);
     WriteOption("sections", options.Sections);
 }
예제 #2
0
        private static int ListPatterns(ListPatternsCommandLineOptions commandLineOptions)
        {
            var options = new ListPatternsCommandOptions();

            if (!commandLineOptions.TryParse(options))
            {
                return(2);
            }

            return(Execute(new ListPatternsCommand(options)));
        }
예제 #3
0
        public bool TryParse(ListPatternsCommandOptions options)
        {
            char?value = null;

            if (Value != null)
            {
                if (!TryParseChar(Value, out char ch))
                {
                    return(false);
                }

                value = ch;
            }

            if (!TryParseAsEnumFlags(
                    Options,
                    OptionNames.Options,
                    out RegexOptions regexOptions,
                    provider: OptionValueProviders.RegexOptionsProvider))
            {
                return(false);
            }

            if (!TryParseAsEnumValues(
                    Section,
                    OptionNames.Section,
                    out ImmutableArray <SyntaxSection> sections,
                    provider: OptionValueProviders.SyntaxSectionProvider))
            {
                return(false);
            }

            if (!FilterParser.TryParse(
                    Filter,
                    OptionNames.Filter,
                    OptionValueProviders.PatternOptions_List_Provider,
                    out Filter? filter,
                    includedPatternOptions: PatternOptions.IgnoreCase,
                    allowNull: true))
            {
                return(false);
            }

            options.Filter       = filter;
            options.Value        = value;
            options.RegexOptions = regexOptions;
            options.InCharGroup  = CharGroup;
            options.Sections     = sections;

            return(true);
        }
        public bool TryParse(ListPatternsCommandOptions options)
        {
            var baseOptions = (CommonListCommandOptions)options;

            if (!TryParse(baseOptions))
            {
                return(false);
            }

            options = (ListPatternsCommandOptions)baseOptions;

            char?value = null;

            if (Value != null)
            {
                if (!TryParseChar(Value, out char ch))
                {
                    return(false);
                }

                value = ch;
            }

            if (!TryParseAsEnumFlags(Options, OptionNames.Options, out RegexOptions regexOptions, provider: OptionValueProviders.RegexOptionsProvider))
            {
                return(false);
            }

            if (!TryParseAsEnumValues(Section, OptionNames.Section, out ImmutableArray <SyntaxSection> sections, provider: OptionValueProviders.SyntaxSectionProvider))
            {
                return(false);
            }

            options.Value        = value;
            options.RegexOptions = regexOptions;
            options.InCharGroup  = CharGroup;
            options.Sections     = sections;

            return(true);
        }