#!/bin/sh # Generates the eeco.1 Unix man page from docs/USAGE.md. # # Strips the cross-repo-fingerprint HTML logo header and the Prev/Next # nav footer (both render badly in roff), then pipes the cleaned # Markdown through go-md2man. The two strip patterns mirror the Go # implementation at internal/guide/render.go (stripTopHTMLBlock + # stripTrailingNavFooter) but stay independent so the slice does not # add a frozen-surface dependency. # # Run from any cwd; resolves the repo root from this script's location. # Output: dist/eeco.1. Pinned go-md2man version keeps CI byte-stable. set -eu SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" DIST="${ROOT}/dist" SRC="${ROOT}/docs/USAGE.md" if [ ! -f "${SRC}" ]; then echo "error: ${SRC} not found" >&2 exit 1 fi mkdir -p "${DIST}" # Title metadata for the `.TH` roff header. Without these inputs # go-md2man emits an empty header so `man eeco` prints `()` for # name(section). Mirrors gen-packaging.sh's VERSION resolution. VERSION="${VERSION:-$(git -C "${ROOT}" describe --tags --dirty --always 2>/dev/null || echo dev)}" MAN_DATE="${MAN_DATE:-$(date -u +%Y-%m-%d)}" TMP_MD="$(mktemp "${DIST}/eeco.usage.XXXXXX.md")" trap 'rm -f "${TMP_MD}"' EXIT # Strip: # 1. Top HTML block: from `