Skip to content

Commit

Permalink
Add --silent option to return nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Aug 29, 2024
1 parent c3bdbfb commit 8713565
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ome2024_ngff_challenge/resave.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,10 @@ def write(
config.zr_write_text(filename, text)


def main(ns: argparse.Namespace) -> int:
def main(ns: argparse.Namespace) -> int | None:
"""
If no images are converted, raises
SystemExit. Otherwise, return the number of images.
If no images are converted, raises SystemExit.
Otherwise, return the number of images, unless --silent.
"""

converted: int = 0
Expand Down Expand Up @@ -550,6 +550,11 @@ def main(ns: argparse.Namespace) -> int:

if converted == 0:
raise SystemExit(1)

# Support for nextflow etc where response is interpreted as an error.
if ns.silent:
return None

return converted


Expand Down Expand Up @@ -675,6 +680,7 @@ def cli(subparsers: argparse._SubParsersAction):
default=16,
help="number of simultaneous write threads",
)
parser.add_argument("--silent", action="store_true", help="Command returns nothing")

# Very recommended metadata (SHOULD!)
def license_action(group, arg: str, url: str, recommended: bool = True):
Expand Down

0 comments on commit 8713565

Please sign in to comment.