#!/usr/bin/env bash # Regenerate any files that use Cog. # # Among other things, this is used to create the per-README list of # the individual scripts and files in this repo. # # Here Cog is Ned Batchelder's file generation tool, described here: # https://nedbatchelder.com/code/cog set -o errexit set -o nounset if [[ "$@" =~ "--check" ]]; then action="check_only" else action="apply_changes" fi # Flags: # -I = ignore binary files # files=$( find . -type f -not -path "./.venv/*" -not -path "./.git/*" \ -exec grep -rIl "\[\[\[cog" {} + | sort) for f in $files; do if [[ $(basename "$f") == "caddyfmt" ]]; then continue fi if [[ "$action" == "check_only" ]]; then cog -c --check "$f" else cog -c -r "$f" fi done