"""Annotate batch command implementation."""

from __future__ import annotations

from ..batch.state.lifecycle import update_batch_note
from ..batch.source.selector import require_plain_batch_name
import sys
from ..data.undo.checkpoints import undo_checkpoint
from ..i18n import _
from ..utils.git_repository import require_git_repository


def command_annotate_batch(batch_name: str, note: str) -> None:
    """Add or update batch description."""
    require_git_repository()
    batch_name = require_plain_batch_name(batch_name, "annotate")
    with undo_checkpoint(f"annotate {batch_name}", worktree_paths=[]):
        update_batch_note(batch_name, note)
    print(_("✓ Updated note for batch '{name}'").format(name=batch_name), file=sys.stderr)
