fix: update usage instructions to support optional group argument in package installation scripts
This commit is contained in:
@@ -3,12 +3,14 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
if [ $# -ne 1 ]; then
|
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
|
||||||
echo "Usage: $0 <dotfiles_directory>"
|
echo "Usage: $0 <dotfiles_directory> [group]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dotfiles_dir="$1"
|
dotfiles_dir="$1"
|
||||||
|
# Optional group argument (e.g., base.txt)
|
||||||
|
group_arg="${2:-}"
|
||||||
# Source shared utilities
|
# Source shared utilities
|
||||||
source "$dotfiles_dir/scripts/utils.sh"
|
source "$dotfiles_dir/scripts/utils.sh"
|
||||||
|
|
||||||
@@ -101,8 +103,15 @@ install_package_lists() {
|
|||||||
|
|
||||||
# Determine which groups to install
|
# Determine which groups to install
|
||||||
local selected_groups=()
|
local selected_groups=()
|
||||||
# Determine interactive mode: forced via INTERACTIVE=1 or a real interactive shell
|
if [ -n "$group_arg" ]; then
|
||||||
if [ "${INTERACTIVE:-0}" -eq 1 ] || is_interactive; 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:"
|
echo "Available package groups:"
|
||||||
for pkg in "${package_files[@]}"; do
|
for pkg in "${package_files[@]}"; do
|
||||||
if [ -f "$packages_dir/$pkg" ]; then
|
if [ -f "$packages_dir/$pkg" ]; then
|
||||||
@@ -123,9 +132,6 @@ install_package_lists() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
# Non-interactive: install only the base group
|
|
||||||
selected_groups=("base.txt")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Loop through selected package lists
|
# Loop through selected package lists
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# scripts/30-install-packages.sh - Install packages from package lists
|
# scripts/30-install-packages.sh - Wrapper to invoke packages module
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
@@ -9,16 +9,19 @@ source "$SCRIPT_DIR/utils.sh"
|
|||||||
|
|
||||||
# Run module when called directly
|
# Run module when called directly
|
||||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
if [ $# -ne 1 ]; then
|
if [ $# -ne 1 ] && [ $# -ne 2 ]; then
|
||||||
log_error "Usage: $0 <dotfiles_directory>"
|
log_error "Usage: $0 <dotfiles_directory> [group]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
dotfiles_dir="$1"
|
dotfiles_dir="$1"
|
||||||
module_script="$dotfiles_dir/packages/install.sh"
|
module_script="$dotfiles_dir/packages/install.sh"
|
||||||
|
# Group to install, default to base.txt
|
||||||
|
group_arg="${2:-base.txt}"
|
||||||
|
|
||||||
if [ ! -f "$module_script" ]; then
|
if [ ! -f "$module_script" ]; then
|
||||||
log_error "Module script not found: $module_script"
|
log_error "Module script not found: $module_script"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
bash "$module_script" "$dotfiles_dir"
|
# Always invoke module with desired group
|
||||||
|
bash "$module_script" "$dotfiles_dir" "$group_arg"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user