Skip to main content

text/recog

1#!/usr/bin/env bash
2# Regenerate any files that use Cog.
3#
4# Among other things, this is used to create the per-README list of
5# the individual scripts and files in this repo.
6#
7# Here Cog is Ned Batchelder's file generation tool, described here:
8# https://nedbatchelder.com/code/cog
10set -o errexit
11set -o nounset
13if [[ "$@" =~ "--check" ]]; then
14 action="check_only"
15else
16 action="apply_changes"
17fi
19# Flags:
20# -I = ignore binary files
22files=$(
23 find . -type f -not -path "./.venv/*" -not -path "./.git/*" \
24 -exec grep -rIl "\[\[\[cog" {} + | sort)
26for f in $files; do
27 if [[ $(basename "$f") == "caddyfmt" ]]; then
28 continue
29 fi
31 if [[ "$action" == "check_only" ]]; then
32 cog -c --check "$f"
33 else
34 cog -c -r "$f"
35 fi
36done