"""First-time setup: create master password."""

import typer

from mb_stash.cli.context import use_context
from mb_stash.core.crypto import DEFAULT_SCRYPT_N


def init(
    ctx: typer.Context,
    *,
    scrypt_n: int = typer.Option(default=DEFAULT_SCRYPT_N, help="scrypt N parameter (cost factor, must be a power of 2)."),
) -> None:
    """First-time setup: create master password."""
    app = use_context(ctx)
    password: str = typer.prompt("Create master password", hide_input=True, confirmation_prompt=True)
    app.core.stash.init(password, scrypt_n=scrypt_n)
    app.out.print_init_done()
