1
0

fix: enhance package installation prompt for better user interaction

This commit is contained in:
2025-08-05 00:00:50 -05:00
parent f634c3a9d1
commit e5202c601f

View File

@@ -98,31 +98,51 @@ install_package_lists() {
# Define package group order # Define package group order
local package_files=("base.txt" "cli-tools.txt" "dev.txt" "gui.txt") local package_files=("base.txt" "cli-tools.txt" "dev.txt" "gui.txt")
for package_file in "${package_files[@]}"; do # Determine which groups to install
local file_path="$packages_dir/$package_file" local selected_groups=()
if [ -f "$file_path" ]; then if is_interactive; then
# Prompt per group echo "Available package groups:"
if is_interactive; then for pkg in "${package_files[@]}"; do
read -rp "Install packages from $package_file? [y/N] " answer if [ -f "$packages_dir/$pkg" ]; then
if [[ ! $answer =~ ^[Yy] ]]; then echo " - $pkg"
log_info "Skipping $package_file"
continue
fi
fi
log_info "Installing packages from $package_file..."
local packages
packages=$(read_package_file "$file_path")
if [ -n "$packages" ]; then
read -ra package_array <<< "$packages"
install_packages "$package_manager" "${package_array[@]}"
log_success "Completed installation from $package_file"
else
log_info "No packages found in $package_file"
fi fi
done
read -rp "Enter groups to install (comma-separated or 'all'): " choice
if [[ "$choice" =~ ^([Aa]ll)$ ]]; then
selected_groups=("${package_files[@]}")
else else
IFS=',' read -ra parts <<< "$choice"
for part in "${parts[@]}"; do
grp="${part// /}"
if [[ " ${package_files[*]} " == *"$grp"* ]]; then
selected_groups+=("$grp")
else
log_warning "Unknown package group: $grp"
fi
done
fi
else
selected_groups=("${package_files[@]}")
fi
# Loop through selected package lists
for package_file in "${selected_groups[@]}"; do
file_path="$packages_dir/$package_file"
if [ ! -f "$file_path" ]; then
log_info "Package file $package_file not found, skipping" log_info "Package file $package_file not found, skipping"
continue
fi
log_info "Installing packages from $package_file..."
local packages
packages=$(read_package_file "$file_path")
if [ -n "$packages" ]; then
read -ra package_array <<< "$packages"
install_packages "$package_manager" "${package_array[@]}"
log_success "Completed installation from $package_file"
else
log_info "No packages found in $package_file"
fi fi
done done
} }