- Replace bare string with Editor in choose.rs typing input - Support ←/→ (left/right arrow keys) for cursor movement - Add Home/End, ctrl-a/ctrl-e, Delete, Up/Down between lines - Keep ctrl-w (kill word), add ctrl-u (kill line) - Render cursor marker ▏ at actual position in multi-line answers - Update help text to mention cursor movement - Add test: type, move cursor, insert character mid-text Also: delete 4 comment lines from scripts/lint-comments.sh (tautology). Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
58 lines
1.8 KiB
Bash
Executable File
58 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
cd "$(git rev-parse --show-toplevel)"
|
|
|
|
baseline=.comment-baseline
|
|
|
|
rust='^[[:space:]]*//|[;{},)][[:space:]]+//[[:space:]]'
|
|
rust_ok='^[[:space:]]*// (SAFETY:|rustfmt::|clippy::)'
|
|
hash='^[[:space:]]*#'
|
|
hash_ok='^[[:space:]]*#(!|[[:space:]]*(shellcheck|yaml-language-server|nolint))'
|
|
|
|
count() {
|
|
case "$1" in
|
|
*.rs) grep -E "$rust" "$1" | grep -vEc "$rust_ok" || true ;;
|
|
*) grep -E "$hash" "$1" | grep -vEc "$hash_ok" || true ;;
|
|
esac
|
|
}
|
|
|
|
current=$(
|
|
git ls-files '*.rs' '*.sh' '*.py' '*.nix' '*.yml' '*.yaml' | while read -r f; do
|
|
[ -f "$f" ] || continue
|
|
n=$(count "$f")
|
|
if [ "$n" -gt 0 ]; then echo "$n $f"; fi
|
|
done | sort -k2
|
|
)
|
|
|
|
if [ "${1:-}" = "--update" ]; then
|
|
printf '%s\n' "$current" | sed '/^$/d' > "$baseline"
|
|
echo "baseline written: $(wc -l < "$baseline") files, $(awk '{s+=$1} END {print s+0}' "$baseline") comment lines"
|
|
exit 0
|
|
fi
|
|
|
|
touch "$baseline"
|
|
fail=0
|
|
while read -r n f; do
|
|
[ -n "${f:-}" ] || continue
|
|
allowed=$(awk -v f="$f" '$2 == f {print $1}' "$baseline")
|
|
allowed=${allowed:-0}
|
|
if [ "$n" -gt "$allowed" ]; then
|
|
echo "FAIL $f: $n comment lines, allowed $allowed. Delete the comment; if it records a decision, write an ADR in docs/adr/."
|
|
fail=1
|
|
elif [ "$n" -lt "$allowed" ]; then
|
|
echo "FAIL $f: $n comment lines, baseline says $allowed. Run scripts/lint-comments.sh --update to lock in the cleanup."
|
|
fail=1
|
|
fi
|
|
done <<< "$current"
|
|
|
|
while read -r n f; do
|
|
[ -n "${f:-}" ] || continue
|
|
if ! printf '%s\n' "$current" | awk -v f="$f" '$2 == f {found=1} END {exit !found}'; then
|
|
echo "FAIL $f: baseline lists $n comment lines but the file has none. Run scripts/lint-comments.sh --update."
|
|
fail=1
|
|
fi
|
|
done < "$baseline"
|
|
|
|
[ "$fail" -eq 0 ] && echo "comment lint ok"
|
|
exit "$fail"
|