Exemplo n.º 1
0
        internal MatchOutputInfo CreateOutputInfo(string input, Match match)
        {
            if (ContentDisplayStyle != ContentDisplayStyle.ValueDetail)
            {
                return(null);
            }

            int groupNumber = ContentFilter.GroupNumber;

            return(MatchOutputInfo.Create(
                       MatchData.Create(input, ContentFilter.Regex, match),
                       groupNumber,
                       includeGroupNumber: groupNumber >= 0,
                       includeCaptureNumber: false,
                       new OutputCaptions(shortMatch: "")));
        }
Exemplo n.º 2
0
        protected override CommandResult ExecuteCore(CancellationToken cancellationToken = default)
        {
            MatchData matchData = MatchData.Create(
                Options.Input,
                Options.Filter.Regex,
                Options.MaxCount,
                cancellationToken);

            var outputWriter = new OutputWriter(Options.HighlightOptions);

            int count = outputWriter.WriteMatches(matchData, Options, cancellationToken);

            if (count > 0)
            {
                WriteLine();
            }

            if (ShouldLog(Verbosity.Detailed) ||
                Options.IncludeSummary)
            {
                Verbosity verbosity = (Options.IncludeSummary) ? Verbosity.Minimal : Verbosity.Detailed;

                WriteGroups(matchData.GroupDefinitions, verbosity: verbosity);
                WriteLine(verbosity);

                if (Options.ContentDisplayStyle == ContentDisplayStyle.Value &&
                    Options.ModifyOptions.HasAnyFunction)
                {
                    WriteCount("Values", count, Colors.Message_OK, verbosity);
                }
                else
                {
                    WriteCount("Matches", matchData.Count, Colors.Message_OK, verbosity);

                    if (count != matchData.Count)
                    {
                        Write("  ", Colors.Message_OK, verbosity);
                        WriteCount("Captures", count, Colors.Message_OK, verbosity);
                    }
                }

                WriteLine(verbosity);
            }

            return((count > 0) ? CommandResult.Success : CommandResult.NoMatch);
        }