@@ -86,41 +86,74 @@ detect_prerequisites() {
8686
8787_prereq_warnings=$( detect_prerequisites)
8888
89+ # ── Parse --dryrun flag (position-independent) ────────────────────────────────
90+ DRYRUN=' '
91+ _args_filtered=()
92+ for _arg in " $@ " ; do
93+ if [[ " $_arg " == ' --dryrun' ]]; then
94+ DRYRUN=1
95+ else
96+ _args_filtered+=(" $_arg " )
97+ fi
98+ done
99+ set -- " ${_args_filtered[@]+" ${_args_filtered[@]} " } "
100+
89101TARGET_REPO=" ${1:- $(git rev-parse --show-toplevel)} "
90102PLUGIN_ROOT=" ${2:- $(cd " $( dirname " $0 " ) /.." && pwd)} "
91103
92104# Ensure TARGET_REPO is a git repository so the dso shim can locate
93105# workflow-config.conf via `git rev-parse --show-toplevel`.
94106if ! git -C " $TARGET_REPO " rev-parse --show-toplevel > /dev/null 2>&1 ; then
95- git -C " $TARGET_REPO " init -q
107+ if [[ -z " $DRYRUN " ]]; then
108+ git -C " $TARGET_REPO " init -q
109+ else
110+ echo " [dryrun] Would run: git init -q in $TARGET_REPO "
111+ fi
96112fi
97113
98- mkdir -p " $TARGET_REPO /.claude/scripts/"
99- cp " $PLUGIN_ROOT /templates/host-project/dso" " $TARGET_REPO /.claude/scripts/dso"
100- chmod +x " $TARGET_REPO /.claude/scripts/dso"
114+ if [[ -z " $DRYRUN " ]]; then
115+ mkdir -p " $TARGET_REPO /.claude/scripts/"
116+ cp " $PLUGIN_ROOT /templates/host-project/dso" " $TARGET_REPO /.claude/scripts/dso"
117+ chmod +x " $TARGET_REPO /.claude/scripts/dso"
118+ else
119+ echo " [dryrun] Would copy $PLUGIN_ROOT /templates/host-project/dso -> $TARGET_REPO /.claude/scripts/dso (chmod +x)"
120+ fi
101121
102122CONFIG=" $TARGET_REPO /workflow-config.conf"
103- if grep -q ' ^dso\.plugin_root=' " $CONFIG " 2> /dev/null; then
104- # Update existing entry (idempotent)
105- sed -i.bak " s|^dso\.plugin_root=.*|dso.plugin_root=$PLUGIN_ROOT |" " $CONFIG " && rm -f " $CONFIG .bak"
123+ if [[ -z " $DRYRUN " ]]; then
124+ if grep -q ' ^dso\.plugin_root=' " $CONFIG " 2> /dev/null; then
125+ # Update existing entry (idempotent)
126+ sed -i.bak " s|^dso\.plugin_root=.*|dso.plugin_root=$PLUGIN_ROOT |" " $CONFIG " && rm -f " $CONFIG .bak"
127+ else
128+ printf ' dso.plugin_root=%s\n' " $PLUGIN_ROOT " >> " $CONFIG "
129+ fi
106130else
107- printf ' dso.plugin_root=%s\n ' " $PLUGIN_ROOT " >> " $CONFIG "
131+ echo " [dryrun] Would write dso.plugin_root=$PLUGIN_ROOT to $CONFIG "
108132fi
109133
110134# ── Copy example config files (only if absent — never overwrite) ──────────────
111135TARGET_PRECOMMIT=" $TARGET_REPO /.pre-commit-config.yaml"
112- if [ ! -f " $TARGET_PRECOMMIT " ]; then
113- cp " $PLUGIN_ROOT /examples/pre-commit-config.example.yaml" " $TARGET_PRECOMMIT "
114- fi
136+ if [[ -z " $DRYRUN " ]]; then
137+ if [ ! -f " $TARGET_PRECOMMIT " ]; then
138+ cp " $PLUGIN_ROOT /examples/pre-commit-config.example.yaml" " $TARGET_PRECOMMIT "
139+ fi
115140
116- mkdir -p " $TARGET_REPO /.github/workflows"
117- if [ ! -f " $TARGET_REPO /.github/workflows/ci.yml" ]; then
118- cp " $PLUGIN_ROOT /examples/ci.example.yml" " $TARGET_REPO /.github/workflows/ci.yml"
141+ mkdir -p " $TARGET_REPO /.github/workflows"
142+ if [ ! -f " $TARGET_REPO /.github/workflows/ci.yml" ]; then
143+ cp " $PLUGIN_ROOT /examples/ci.example.yml" " $TARGET_REPO /.github/workflows/ci.yml"
144+ fi
145+ else
146+ echo " [dryrun] Would copy pre-commit-config.example.yaml -> $TARGET_PRECOMMIT "
147+ echo " [dryrun] Would copy ci.example.yml -> $TARGET_REPO /.github/workflows/ci.yml"
119148fi
120149
121150# ── Register pre-commit hooks (must come AFTER config copy) ───────────────────
122- if command -v pre-commit > /dev/null 2>&1 && [ -f " $TARGET_PRECOMMIT " ]; then
123- (cd " $TARGET_REPO " && pre-commit install && pre-commit install --hook-type pre-push) || true
151+ if [[ -z " $DRYRUN " ]]; then
152+ if command -v pre-commit > /dev/null 2>&1 && [ -f " $TARGET_PRECOMMIT " ]; then
153+ (cd " $TARGET_REPO " && pre-commit install && pre-commit install --hook-type pre-push) || true
154+ fi
155+ else
156+ echo " [dryrun] Would run: pre-commit install && pre-commit install --hook-type pre-push"
124157fi
125158
126159# ── Optional dependency detection (non-blocking) ──────────────────────────────
0 commit comments