fix: auto-install when profile specified via command line

Problem:
- Running 'curl ... | bash -s core' showed preview and waited for input
- User had to press Y to proceed even though profile was specified
- Defeats the purpose of one-command installation

Solution:
- Add NON_INTERACTIVE flag to track command-line profile usage
- Set NON_INTERACTIVE=true when profile argument provided
- Skip confirmation prompt when NON_INTERACTIVE=true
- Show 'Installing automatically (profile specified)...' message

Behavior:
Before:
  curl ... | bash -s core
  → Shows preview, waits for Y/n input

After:
  curl ... | bash -s core
  → Shows preview, installs automatically

Interactive mode still works:
  bash install.sh
  → Shows menu, asks for confirmation (as expected)

This makes profile-based installation truly one-command with no interaction needed.
This commit is contained in:
darrenhinde 2025-11-18 14:24:27 +00:00
parent a9f119e83e
commit 532e17ce01

View file

@ -55,6 +55,7 @@ TEMP_DIR="/tmp/opencode-installer-$$"
SELECTED_COMPONENTS=()
INSTALL_MODE=""
PROFILE=""
NON_INTERACTIVE=false
#############################################################################
# Utility Functions
@ -498,6 +499,12 @@ show_installation_preview() {
[ ${#configs[@]} -gt 0 ] && echo -e "${CYAN}Config (${#configs[@]}):${NC} ${configs[*]##*:}"
echo ""
# Skip confirmation if profile was provided via command line
if [ "$NON_INTERACTIVE" = true ]; then
print_info "Installing automatically (profile specified)..."
perform_installation
else
read -p "Proceed with installation? [Y/n]: " confirm
if [[ $confirm =~ ^[Nn] ]]; then
@ -506,6 +513,7 @@ show_installation_preview() {
fi
perform_installation
fi
}
#############################################################################
@ -808,18 +816,22 @@ main() {
core|--core)
INSTALL_MODE="profile"
PROFILE="core"
NON_INTERACTIVE=true
;;
developer|--developer)
INSTALL_MODE="profile"
PROFILE="developer"
NON_INTERACTIVE=true
;;
full|--full)
INSTALL_MODE="profile"
PROFILE="full"
NON_INTERACTIVE=true
;;
advanced|--advanced)
INSTALL_MODE="profile"
PROFILE="advanced"
NON_INTERACTIVE=true
;;
list|--list)
check_dependencies