summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Fink2019-08-19 20:07:06 +0200
committerDennis Fink2019-08-19 20:07:06 +0200
commit5023b0fb4c7e9b4816169c121b192d961e9a2450 (patch)
treef509260cf0eeb2b8e130ac0a6ddc834439a2a544
parent6bf9b289c268387dd3c15e65e0379813508f075b (diff)
downloadpatternutils-5023b0fb4c7e9b4816169c121b192d961e9a2450.tar.gz
patternutils-5023b0fb4c7e9b4816169c121b192d961e9a2450.zip
Added stream option to pmatch
Diffstat (limited to '')
-rw-r--r--patternutils/commands/pmatch.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/patternutils/commands/pmatch.py b/patternutils/commands/pmatch.py
index c5800fe..481ba39 100644
--- a/patternutils/commands/pmatch.py
+++ b/patternutils/commands/pmatch.py
@@ -62,6 +62,8 @@ def apply_regex(
help='match on full path instead of only filename')
@click.option('-p', '--use-predefined-pattern', is_flag=True, default=False,
help='use predefined regex pattern')
+@click.option('--stream', is_flag=True, default=False,
+ help='Output a stream of objects instead a list of objects')
@click.option('-v', '--verbose', is_flag=True, default=False,
help='explain what is being done')
@click.version_option()
@@ -74,6 +76,7 @@ def pmatch(
abort_on_no_match: bool,
match_full_path: bool,
use_predefined_pattern: bool,
+ stream: bool,
verbose: bool,
) -> None:
@@ -104,7 +107,11 @@ def pmatch(
if has_invalid_matches and abort_on_no_match:
raise SystemExit
- click.echo(json.dumps(matches))
+ if stream:
+ for m in matches:
+ click.echo(json.dumps(m))
+ else:
+ click.echo(json.dumps(matches))
if __name__ == '__main__':