This repository has been archived on 2026-08-17. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files

45 lines
635 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
log() {
printf '[codex] %s\n' "$*"
}
warn() {
printf '[codex][warn] %s\n' "$*" >&2
}
die() {
printf '[codex][error] %s\n' "$*" >&2
exit 1
}
have() {
command -v "$1" >/dev/null 2>&1
}
repo_root() {
git rev-parse --show-toplevel 2>/dev/null || pwd
}
cd_repo_root() {
cd "$(repo_root)"
}
ensure_file() {
local path="$1"
[[ -f "$path" ]] || die "Required file not found: $path"
}
ensure_dir() {
local path="$1"
mkdir -p "$path"
}
append_if_missing() {
local line="$1"
local file="$2"
touch "$file"
grep -Fqx "$line" "$file" || printf '%s\n' "$line" >> "$file"
}