feat: Enhance setup-profiles.bash

Move pre-requisites check in a separate function
This commit is contained in:
xavier committed 2025-07-13 00:06:13 +02:00
1 parent 91a4ef1c1a
commit ae01546c0a
1 file changed
+12 -8
+12 -8
View File
@@ -4,13 +4,15 @@ BASEDIR=$(cd "$(dirname "$0")" && pwd)
echo "BASEDIR=$BASEDIR" echo "BASEDIR=$BASEDIR"
# Prerequisite check for yq check_prerequisites() {
if ! command -v yq &> /dev/null # Prerequisite check for yq
then if ! command -v yq &> /dev/null
echo "Error: yq is not installed." then
echo "Please install yq to use this script. Refer to https://github.com/mikefarah/yq#install for installation methods." echo "Error: yq is not installed."
exit 1 echo "Please install yq to use this script. Refer to https://github.com/mikefarah/yq#install for installation methods."
fi exit 1
fi
}
update_profile() { update_profile() {
local profile_file="$1" local profile_file="$1"
@@ -35,6 +37,8 @@ update_profile() {
cd "$BASEDIR" || exit cd "$BASEDIR" || exit
check_prerequisites
if [ "$#" -eq 0 ]; then if [ "$#" -eq 0 ]; then
# No arguments, update all profiles # No arguments, update all profiles
echo "No profile specified, updating all profiles..." echo "No profile specified, updating all profiles..."
@@ -50,4 +54,4 @@ else
echo "Error: Profile file '$file_path' not found. Skipping." echo "Error: Profile file '$file_path' not found. Skipping."
fi fi
done done
fi fi