summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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__':