"""Unlock with master password."""

import time

import typer

from mb_stash.cli.context import use_context


def unlock(ctx: typer.Context) -> None:
    """Unlock with master password."""
    app = use_context(ctx)
    password = typer.prompt("Enter master password", hide_input=True)
    t0 = time.monotonic()
    app.core.service.unlock(password)
    elapsed = time.monotonic() - t0
    app.out.print_unlocked(elapsed=elapsed)
