"""List stored keys."""

import typer

from mb_stash.cli.context import password_prompt, use_context


def list_(ctx: typer.Context, filter_: str | None = typer.Argument(default=None, help="Filter keys by substring")) -> None:
    """List stored keys, optionally filter by substring."""
    app = use_context(ctx)
    keys = app.core.service.list_keys(filter_, password_prompt=password_prompt)
    app.out.print_list(keys)
