#!/bin/bash
# Code generated by Claude Code

set -e

usage() {
    echo "Usage: $0 <source-file> <output.md>" >&2
    exit 2
}

if [[ $# -ne 2 ]]; then
    usage
fi

src="$1"
dest="$2"

if [[ ! -f "$src" ]]; then
    echo "ERROR: source file not found: ${src}" >&2
    exit 1
fi

# pod2markdown finds POD directives (=head1, =over, etc.) regardless
# of surrounding non-POD content, so it works directly on shell
# scripts that embed POD in a heredoc.
pod2markdown "$src" > "$dest"

if [[ ! -s "$dest" ]]; then
    rm -f "$dest"
    echo "ERROR: no POD found in ${src}" >&2
    exit 1
fi

echo "Wrote ${dest}"
# Code generated by Claude Code
