Skip to content

Commit

Permalink
Merge pull request #43 from will-moore/resave_return_nothing
Browse files Browse the repository at this point in the history
resave main() returns nothing to indicate no error
  • Loading branch information
joshmoore authored Aug 30, 2024
2 parents 4160338 + 0f556a1 commit 0ea3b95
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 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,11 @@ def cli(subparsers: argparse._SubParsersAction):
default=16,
help="number of simultaneous write threads",
)
parser.add_argument(
"--silent",
action="store_true",
help="Command returns nothing; required for nextflow",
)

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

0 comments on commit 0ea3b95

Please sign in to comment.