From 900b67a26130c8fccbcb338fcb666f03779b181f Mon Sep 17 00:00:00 2001 From: Till Hartmann Date: Tue, 14 Jan 2025 15:46:07 +0100 Subject: [PATCH] feat: add `--filter-status` option for controlling which landing zones are listed (#239) --- src/cubi_tk/sodar/lz_list.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/cubi_tk/sodar/lz_list.py b/src/cubi_tk/sodar/lz_list.py index cddf421c..b92519a2 100644 --- a/src/cubi_tk/sodar/lz_list.py +++ b/src/cubi_tk/sodar/lz_list.py @@ -12,6 +12,9 @@ from ..common import load_toml_config +# TODO: Obtain from somewhere else, e.g. sodar-cli or sodar API or sodar-core or … +LANDING_ZONE_STATES = ["ACTIVE", "FAILED", "VALIDATING"] + class ListLandingZoneCommand: """Implementation of the ``landing-zone-list`` command.""" @@ -62,6 +65,15 @@ def setup_argparse(cls, parser: argparse.ArgumentParser) -> None: help="Format string for printing, e.g. %%(uuid)s", ) + parser.add_argument( + "--filter-status", + dest="filter_status", + default=LANDING_ZONE_STATES, + action="append", + choices=LANDING_ZONE_STATES, + help="Filter landing zone by status. Defaults to listing all.", + ) + parser.add_argument("project_uuid", help="UUID of project to create the landing zone in.") @classmethod @@ -101,7 +113,7 @@ def execute(self) -> typing.Optional[int]: key=lambda lz: lz.date_modified, ) for lz in existing_lzs: - if lz.status != "ACTIVE": + if lz.status not in self.args.filter_status: continue values = cattr.unstructure(lz) if self.args.format_string: