Skip to content

Commit 67e56c8

Browse files
betegonclaude
andcommitted
feat(install): add --init flag for ephemeral wizard runs
Adds `--init` to the install script so users can run the setup wizard without permanently installing the CLI: curl -fsSL https://cli.sentry.dev/install | bash -s -- --init Downloads the binary to a temp path, runs `sentry init`, and cleans up. Skips download entirely if `sentry` is already in PATH. All args after `--init` are forwarded to the wizard (--dry-run, --yes, org/project). Closes #682 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 79e72c1 commit 67e56c8

File tree

1 file changed

+44
-20
lines changed

1 file changed

+44
-20
lines changed

install

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Usage: install [options]
8383
Options:
8484
-h, --help Display this help message
8585
-v, --version <version> Install a specific version (e.g., 0.2.0) or "nightly"
86+
--init Run \`sentry init\` ephemerally without installing the CLI
8687
--no-modify-path Don't modify shell config files (.zshrc, .bashrc, etc.)
8788
--no-completions Don't install shell completions
8889
@@ -94,6 +95,7 @@ Examples:
9495
curl -fsSL https://cli.sentry.dev/install | bash
9596
curl -fsSL https://cli.sentry.dev/install | bash -s -- --version nightly
9697
curl -fsSL https://cli.sentry.dev/install | bash -s -- --version 0.19.0
98+
curl -fsSL https://cli.sentry.dev/install | bash -s -- --init
9799
SENTRY_VERSION=nightly curl -fsSL https://cli.sentry.dev/install | bash
98100
SENTRY_INSTALL_DIR=~/.local/bin curl -fsSL https://cli.sentry.dev/install | bash
99101
EOF
@@ -102,6 +104,8 @@ EOF
102104
requested_version="${SENTRY_VERSION:-}"
103105
no_modify_path=false
104106
no_completions=false
107+
init_mode=false
108+
init_args=()
105109
while [[ $# -gt 0 ]]; do
106110
case "$1" in
107111
-h|--help) usage; exit 0 ;;
@@ -113,6 +117,13 @@ while [[ $# -gt 0 ]]; do
113117
die "Error: --version requires a version argument" "args"
114118
fi
115119
;;
120+
--init)
121+
init_mode=true
122+
shift
123+
# Remaining args are forwarded to `sentry init`
124+
init_args=("$@")
125+
break
126+
;;
116127
--no-modify-path)
117128
no_modify_path=true
118129
shift
@@ -125,6 +136,12 @@ while [[ $# -gt 0 ]]; do
125136
esac
126137
done
127138

139+
# In init mode, skip download if the CLI is already installed.
140+
if [[ "$init_mode" == "true" ]] && command -v sentry >/dev/null 2>&1; then
141+
echo -e "${MUTED}sentry found in PATH, running init directly...${NC}"
142+
exec sentry init ${init_args[@]+"${init_args[@]}"}
143+
fi
144+
128145
# Detect OS
129146
case "$(uname -s)" in
130147
Darwin*) os="darwin" ;;
@@ -253,26 +270,33 @@ fi
253270

254271
chmod +x "$tmp_binary"
255272

256-
# Delegate installation and configuration to the binary itself.
257-
# setup --install handles: directory selection, binary placement, PATH,
258-
# completions, agent skills, and the welcome message.
259-
# --channel persists the release channel so future `sentry cli upgrade`
260-
# calls track the same channel without requiring a flag.
261-
if [[ "$requested_version" == "nightly" ]]; then
262-
channel="nightly"
273+
if [[ "$init_mode" == "true" ]]; then
274+
# Ephemeral mode: run the wizard and clean up. The EXIT trap (set earlier)
275+
# removes the temp binary. The binary inherits the terminal's stdin (the
276+
# pipe is already consumed by bash), so interactive prompts work normally.
277+
"$tmp_binary" init ${init_args[@]+"${init_args[@]}"}
263278
else
264-
channel="stable"
265-
fi
266-
setup_args="--install --method curl --channel $channel"
267-
if [[ "$no_modify_path" == "true" ]]; then
268-
setup_args="$setup_args --no-modify-path"
269-
fi
270-
if [[ "$no_completions" == "true" ]]; then
271-
setup_args="$setup_args --no-completions"
272-
fi
279+
# Delegate installation and configuration to the binary itself.
280+
# setup --install handles: directory selection, binary placement, PATH,
281+
# completions, agent skills, and the welcome message.
282+
# --channel persists the release channel so future `sentry cli upgrade`
283+
# calls track the same channel without requiring a flag.
284+
if [[ "$requested_version" == "nightly" ]]; then
285+
channel="nightly"
286+
else
287+
channel="stable"
288+
fi
289+
setup_args="--install --method curl --channel $channel"
290+
if [[ "$no_modify_path" == "true" ]]; then
291+
setup_args="$setup_args --no-modify-path"
292+
fi
293+
if [[ "$no_completions" == "true" ]]; then
294+
setup_args="$setup_args --no-completions"
295+
fi
273296

274-
# Remove trap — setup will handle temp cleanup on success
275-
trap - EXIT
297+
# Remove trap — setup will handle temp cleanup on success
298+
trap - EXIT
276299

277-
# shellcheck disable=SC2086
278-
"$tmp_binary" cli setup $setup_args
300+
# shellcheck disable=SC2086
301+
"$tmp_binary" cli setup $setup_args
302+
fi

0 commit comments

Comments
 (0)