"""abreka wiki delete — remove a wiki page."""

from __future__ import annotations

import click

from abreka.config import find_abreka_dir
from abreka.wiki import WikiPageNotFoundError, delete_wiki_page


@click.command("delete")
@click.argument("slug")
@click.option("--yes", is_flag=True, help="Skip confirmation prompt.")
def delete_cmd(slug: str, yes: bool):
    """Delete a wiki page (user-only operation)."""
    abreka_dir = find_abreka_dir()
    if not yes:
        click.confirm(f"Delete wiki page {slug!r}?", abort=True)
    try:
        delete_wiki_page(abreka_dir, slug)
    except WikiPageNotFoundError as exc:
        raise click.ClickException(str(exc))
    click.echo(f"Deleted {slug}")
