Repository navigation
Add --count option - #5
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by gulliby
Adds a
-c/--countoption that prints only the number of matching records.Before. To answer "how many errors in the last hour" a script had to pipe the records to
wc -l(not available in Windows PowerShell) or parse the--summarytext.After.
--countprints one decimal number and a newline,0when nothing matches:It works with
--since,--until,--level,--grep,-iand-v, adds up all input files (or standard input), and does not count lines that are not records.--counttogether with--summaryis a usage error (logslice: --count conflicts with --summary, exit status 2), checked after the existing option checks and before the--greppattern is compiled. When an input file cannot be read, no count is printed.How.
src/logslice/cli.py(new option, conflict check, counter),README.md(paragraph and options table row),tests/test_count.py(20 new test cases) and one additive edit of the help-words test intests/test_cli.py. No dependency or CI change.