Skip to content

Commit

Permalink
feat: add --filter-status option for controlling which landing zone…
Browse files Browse the repository at this point in the history
…s are listed (#239)
  • Loading branch information
tedil authored Jan 14, 2025
1 parent 581e650 commit 900b67a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/cubi_tk/sodar/lz_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 900b67a

Please sign in to comment.