Exemplo n.º 1
0
        public bool TryParse(MatchCommandOptions options)
        {
            var baseOptions = (RegexCommandOptions)options;

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

            options = (MatchCommandOptions)baseOptions;

            if (!FilterParser.TryParse(Content, OptionNames.Content, OptionValueProviders.PatternOptionsWithoutPartAndNegativeProvider, out Filter? filter))
            {
                return(false);
            }

            if (!TryParseAsEnumFlags(Highlight, OptionNames.Highlight, out HighlightOptions highlightOptions, defaultValue: HighlightOptions.Default, provider: OptionValueProviders.MatchHighlightOptionsProvider))
            {
                return(false);
            }

            options.Filter           = filter !;
            options.HighlightOptions = highlightOptions;
            options.MaxCount         = MaxCount;

            return(true);
        }
Exemplo n.º 2
0
 internal static void WriteMatchCommand(MatchCommandOptions options)
 {
     WriteDisplayFormat("display", options.Format);
     WriteFilter("filter", options.Filter);
     WriteOption("highlight options", options.HighlightOptions);
     WriteInput(options.Input);
     WriteOption("max count", options.MaxCount);
 }
Exemplo n.º 3
0
        private static int Match(MatchCommandLineOptions commandLineOptions)
        {
            var options = new MatchCommandOptions();

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

            return(Execute(new MatchCommand(options)));
        }
Exemplo n.º 4
0
 public int WriteMatches(
     MatchData matchData,
     MatchCommandOptions options,
     in CancellationToken cancellationToken = default)