#!/usr/bin/env bash set -euo pipefail # Copy a CI status template into the project. # Usage: init_ci_status.sh --root DIR --kind tea|glab|gh|curl usage() { echo "Usage: init_ci_status.sh --root DIR --kind tea|glab|gh|curl" >&2 } root= kind= while (($#)); do case "$1" in --root) [[ $# -ge 2 ]] || { usage; exit 2; }; root=$2; shift 2 ;; --kind) [[ $# -ge 2 ]] || { usage; exit 2; }; kind=$2; shift 2 ;; -h|--help) usage; exit 0 ;; *) usage; exit 2 ;; esac done if [[ -z "$root" || -z "$kind" ]]; then usage exit 2 fi case "$kind" in tea|glab|gh|curl) ;; *) echo "Error: --kind must be tea, glab, gh, or curl" >&2; exit 2 ;; esac script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) src=$script_dir/../templates/ci-status/${kind}.sh if [[ ! -f "$src" ]]; then echo "Error: missing template: $src" >&2 exit 2 fi dest=$root/.pouch/builder/ci-status.sh mkdir -p "$(dirname "$dest")" cp "$src" "$dest" chmod +x "$dest" echo "$dest"