From dee755e2919fca3fde6e65a47127a6e7a49797fc Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Tue, 5 May 2026 22:50:27 +0200 Subject: [PATCH] install.sh: add --only and --skip flags for subset installs --- README.md | 10 ++++++++ install.sh | 74 +++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 69 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1a8afde..4644bb5 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,16 @@ chmod +x install.sh Each `.ts` file in `extensions/` is symlinked into `~/.pi/agent/extensions/`. Existing real files are backed up with a timestamp. Re-runs are idempotent. +**Install a subset:** + +```bash +./install.sh --only ssh-controlmaster # just this one +./install.sh --only "ssh-controlmaster,other" # explicit list +./install.sh --skip "git-checkpoint" # all except these +``` + +`--only` and `--skip` accept comma-separated names without the `.ts` suffix. `--only` takes precedence if both are given. + ### Alternative: pi install (local path) Because `package.json` declares a `pi` manifest, you can also register this repo as a pi package: diff --git a/install.sh b/install.sh index 51f3898..bf43cb3 100755 --- a/install.sh +++ b/install.sh @@ -5,9 +5,12 @@ # loads them automatically on every session. Idempotent and non-destructive. # # Usage: -# ./install.sh # install (interactive confirm) -# ./install.sh --yes # install without prompt -# ./install.sh --uninstall # remove symlinks that point into this repo +# ./install.sh install all extensions +# ./install.sh --only ssh-controlmaster install one extension +# ./install.sh --only "ext1,ext2" install a subset +# ./install.sh --skip "ext1,ext2" install all except these +# ./install.sh --yes skip confirmation prompt +# ./install.sh --uninstall remove symlinks that point into this repo set -euo pipefail @@ -49,22 +52,34 @@ require_pi_installed() { # ── args ───────────────────────────────────────────── ACTION="install" ASSUME_YES="no" +ONLY="" # comma-separated names to include (empty = all) +SKIP="" # comma-separated names to exclude (empty = none) while [[ $# -gt 0 ]]; do case "$1" in - --uninstall) ACTION="uninstall"; shift ;; - -y|--yes) ASSUME_YES="yes"; shift ;; + --uninstall) ACTION="uninstall"; shift ;; + -y|--yes) ASSUME_YES="yes"; shift ;; + --only) ONLY="$2"; shift 2 ;; + --only=*) ONLY="${1#--only=}"; shift ;; + --skip) SKIP="$2"; shift 2 ;; + --skip=*) SKIP="${1#--skip=}"; shift ;; -h|--help) cat </dev/null || true + done + fi + fi +} + # ── install ────────────────────────────────────────── do_install() { echo @@ -80,24 +120,28 @@ do_install() { echo require_pi_installed + build_install_set - local extensions=("${EXTENSIONS_SRC}"/*.ts) - if [[ ! -e "${extensions[0]}" ]]; then - warn "No .ts files found in ${EXTENSIONS_SRC}/ — nothing to install." + if [[ ${#INSTALL_SET[@]} -eq 0 ]]; then + warn "No extensions selected — nothing to install." exit 0 fi echo "==> Extensions to symlink into ${EXTENSIONS_DEST}/:" - for src in "${extensions[@]}"; do - printf ' %s\n' "$(basename "$src")" + for n in "${!INSTALL_SET[@]}"; do + printf ' %s.ts\n' "$n" done echo confirm || { echo "Aborted."; exit 0; } echo - for src in "${extensions[@]}"; do + for src in "${EXTENSIONS_SRC}"/*.ts; do + [[ -e "$src" ]] || continue local name name="$(basename "$src")" + local bare="${name%.ts}" + [[ -n "${INSTALL_SET[$bare]:-}" ]] || continue + local dest="${EXTENSIONS_DEST}/${name}" note "Linking ${name}"