1
0

fix: update usage instructions to support optional group argument in package installation scripts

This commit is contained in:
2025-08-05 00:12:43 -05:00
parent 1b9d9424b4
commit 1b55f3f173
2 changed files with 20 additions and 11 deletions

View File

@@ -3,12 +3,14 @@
set -euo pipefail
if [ $# -ne 1 ]; then
echo "Usage: $0 <dotfiles_directory>"
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
echo "Usage: $0 <dotfiles_directory> [group]"
exit 1
fi
dotfiles_dir="$1"
# Optional group argument (e.g., base.txt)
group_arg="${2:-}"
# Source shared utilities
source "$dotfiles_dir/scripts/utils.sh"
@@ -101,8 +103,15 @@ install_package_lists() {
# Determine which groups to install
local selected_groups=()
# Determine interactive mode: forced via INTERACTIVE=1 or a real interactive shell
if [ "${INTERACTIVE:-0}" -eq 1 ] || is_interactive; then
if [ -n "$group_arg" ]; then
# Direct install of specified group
if [[ " ${package_files[*]} " == *" $group_arg"* ]]; then
selected_groups=("$group_arg")
else
log_error "Unknown package group: $group_arg"
exit 1
fi
else
echo "Available package groups:"
for pkg in "${package_files[@]}"; do
if [ -f "$packages_dir/$pkg" ]; then
@@ -123,9 +132,6 @@ install_package_lists() {
fi
done
fi
else
# Non-interactive: install only the base group
selected_groups=("base.txt")
fi
# Loop through selected package lists