fix: enhance package installation prompt for better user interaction
This commit is contained in:
@@ -98,31 +98,51 @@ install_package_lists() {
|
||||
|
||||
# Define package group order
|
||||
local package_files=("base.txt" "cli-tools.txt" "dev.txt" "gui.txt")
|
||||
|
||||
for package_file in "${package_files[@]}"; do
|
||||
local file_path="$packages_dir/$package_file"
|
||||
if [ -f "$file_path" ]; then
|
||||
# Prompt per group
|
||||
if is_interactive; then
|
||||
read -rp "Install packages from $package_file? [y/N] " answer
|
||||
if [[ ! $answer =~ ^[Yy] ]]; then
|
||||
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"
|
||||
|
||||
# Determine which groups to install
|
||||
local selected_groups=()
|
||||
if is_interactive; then
|
||||
echo "Available package groups:"
|
||||
for pkg in "${package_files[@]}"; do
|
||||
if [ -f "$packages_dir/$pkg" ]; then
|
||||
echo " - $pkg"
|
||||
fi
|
||||
done
|
||||
read -rp "Enter groups to install (comma-separated or 'all'): " choice
|
||||
if [[ "$choice" =~ ^([Aa]ll)$ ]]; then
|
||||
selected_groups=("${package_files[@]}")
|
||||
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"
|
||||
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
|
||||
done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user