feat(02-01): refactor flag parsing to while/shift with CLAUDE_ARGS accumulator

This commit is contained in:
Christopher Mühl 2026-04-09 17:09:56 +02:00
parent daf47bd094
commit 72ba48d004
No known key found for this signature in database
GPG key ID: 925AC7D69955293F

View file

@ -1,11 +1,20 @@
# Parse claudebox flags
SKIP_AUDIT=false
DRY_RUN=false
CHECK_MODE=false
SHELL_MODE=false
for arg in "$@"; do
case "$arg" in
--shell) SHELL_MODE=true; shift; break ;;
--) shift; break ;;
*) break ;;
CLAUDE_ARGS=()
while (( $# > 0 )); do
case "$1" in
--yes|-y) SKIP_AUDIT=true ;;
--dry-run) DRY_RUN=true ;;
--check) CHECK_MODE=true ;;
--shell) SHELL_MODE=true ;;
--) shift; CLAUDE_ARGS+=("$@"); break ;;
*) CLAUDE_ARGS+=("$1") ;;
esac
shift
done
# SANDBOX_PATH is injected by flake.nix via makeBinPath (only runtimeInputs, no host PATH)
@ -68,9 +77,9 @@ fi
# Build sandbox command
if [[ "$SHELL_MODE" == true ]]; then
SANDBOX_CMD=("$SANDBOX_BASH" "$@")
SANDBOX_CMD=("$SANDBOX_BASH" "${CLAUDE_ARGS[@]}")
else
SANDBOX_CMD=("$CLAUDE_BIN" --dangerously-skip-permissions "$@")
SANDBOX_CMD=("$CLAUDE_BIN" --dangerously-skip-permissions "${CLAUDE_ARGS[@]}")
fi
# exec bwrap (SAND-04 through SAND-15, UX-06, D-01)