diff options
Diffstat (limited to '')
| -rw-r--r-- | patternutils/commands/prss.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/patternutils/commands/prss.py b/patternutils/commands/prss.py index 2efdfae..bdf35a4 100644 --- a/patternutils/commands/prss.py +++ b/patternutils/commands/prss.py @@ -23,6 +23,12 @@ from .. import utils help="search directories recursively", ) @click.option( + "--abort-on-no-file", + is_flag=True, + default=False, + help="exit if a file can not be found", +) +@click.option( "--stream", is_flag=True, default=False, @@ -43,6 +49,7 @@ def prss( url: str, directory: str, recursive: bool, + abort_on_no_file: bool, stream: bool, human_readable: bool, verbose: bool, @@ -72,6 +79,7 @@ def prss( matches = [] + has_no_file = False for entry in parsed_feed.entries: href = entry.enclosures[0]["href"] @@ -81,6 +89,7 @@ def prss( file_index = filenames.index(file_to_search) except ValueError: click.secho(f"{file_to_search} not found!", fg="red", err=True) + has_no_file = True else: filename = filenames[file_index] direntry = direntries[file_index] @@ -105,6 +114,9 @@ def prss( } matches.append(entry_values) + if abort_on_no_file and has_no_file: + raise SystemExit + if stream: for m in matches: click.echo(utils.json_dumps(m, human_readable)) |
