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
|
||||
|
||||
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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/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
|
||||
|
||||
@@ -9,16 +9,19 @@ source "$SCRIPT_DIR/utils.sh"
|
||||
|
||||
# Run module when called directly
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
if [ $# -ne 1 ]; then
|
||||
log_error "Usage: $0 <dotfiles_directory>"
|
||||
if [ $# -ne 1 ] && [ $# -ne 2 ]; then
|
||||
log_error "Usage: $0 <dotfiles_directory> [group]"
|
||||
exit 1
|
||||
fi
|
||||
dotfiles_dir="$1"
|
||||
module_script="$dotfiles_dir/packages/install.sh"
|
||||
# Group to install, default to base.txt
|
||||
group_arg="${2:-base.txt}"
|
||||
|
||||
if [ ! -f "$module_script" ]; then
|
||||
log_error "Module script not found: $module_script"
|
||||
exit 1
|
||||
fi
|
||||
bash "$module_script" "$dotfiles_dir"
|
||||
# Always invoke module with desired group
|
||||
bash "$module_script" "$dotfiles_dir" "$group_arg"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user