#!/usr/bin/env bash # Writes the CLI reference in README.md from each binary's own --help. # # Every binary a person runs has a `cli_reference` test that renders its # section (see crates/didbot-cli/src/reference.rs). With DIDBOT_BLESS_README # set, a stale section is written; without it, the test fails. `--check` is # the second, which is what the prek hook runs. set -euo pipefail root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" run() { cargo test --quiet --no-fail-fast --manifest-path "$root/Cargo.toml" --workspace --bins cli_reference } if [ "${1-}" = "--check" ]; then if ! run; then echo "gen-cli-reference: README.md's CLI reference is behind the binaries." >&2 echo " run scripts/gen-cli-reference.sh and stage README.md" >&2 exit 1 fi exit 0 fi DIDBOT_BLESS_README=1 run echo "gen-cli-reference: wrote $root/README.md"