Skip to content

Commit

Permalink
Improved implementation of select_project_type() function to
Browse files Browse the repository at this point in the history
use consistent style for variables.
  • Loading branch information
kilo52 committed Dec 20, 2024
1 parent 27826c9 commit 8c372cc
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions libinit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5329,24 +5329,24 @@ function select_project_type() {
_make_func_hl "select_project_type";
logE "Programming error: Illegal function call:";
logE "at: '${BASH_SOURCE[1]}' (line ${BASH_LINENO[0]})";
failure "Programming error: Invalid call to $HYPERLINK_VALUE function: " \
failure "Programming error: Invalid call to ${HYPERLINK_VALUE} function: " \
"No language ID argument specified";
fi
if [ -z "$lang_name" ]; then
_make_func_hl "select_project_type";
logW "No language name argument specified in call" \
"to $HYPERLINK_VALUE function:";
"to ${HYPERLINK_VALUE} function:";
logW "at: '${BASH_SOURCE[1]}' (line ${BASH_LINENO[0]})";
lang_name="$lang_id";
fi
# Check current init level
if (( CURRENT_LVL_NUMBER != 1 )); then
_make_func_hl "select_project_type";
logE "Project types can only be selected at init level 1.";
logE "The call to the $HYPERLINK_VALUE function was made:";
logE "at init level: $CURRENT_LVL_NUMBER";
logE "at: '$CURRENT_LVL_PATH'";
failure "Programming error: Invalid call to $HYPERLINK_VALUE function." \
logE "The call to the ${HYPERLINK_VALUE} function was made:";
logE "at init level: ${CURRENT_LVL_NUMBER}";
logE "at: '${CURRENT_LVL_PATH}'";
failure "Programming error: Invalid call to ${HYPERLINK_VALUE} function." \
"Project types under a given language can only be selected while at" \
"init level 1";
fi
Expand All @@ -5362,7 +5362,7 @@ function select_project_type() {
if [ -d "$dir" ]; then
if [ -n "$PROJECT_INIT_ADDONS_DIR" ]; then
ptype_id="$(basename $dir)";
if [ -f "$PROJECT_INIT_ADDONS_DIR/${lang_id}/${ptype_id}/DISABLE" ]; then
if [ -f "${PROJECT_INIT_ADDONS_DIR}/${lang_id}/${ptype_id}/DISABLE" ]; then
continue;
fi
fi
Expand All @@ -5381,7 +5381,7 @@ function select_project_type() {
for fpath in "${all_ptypes[@]}"; do
if [[ "$fpath" == *"?"* ]]; then
logE "Invalid path encountered:";
logE "'$fpath'";
logE "'${fpath}'";
logE "Path contains an invalid character: '?'";
failure "One or more paths to a component of an addon has an invalid character." \
"Please make sure that the path to the addons directory does not" \
Expand Down Expand Up @@ -5421,19 +5421,19 @@ function select_project_type() {
local n_ptypes=${#project_type_dirs[@]};
if (( n_ptypes == 0 )); then
logE "Cannot prompt for project type selection. No options available";
failure "You have chosen to create a project using $lang_name," \
"however, no type of $lang_name project can be initialized" \
"because no project template files could be found." \
"Please add at least one project type directory under" \
"the '$lang_id' folder.";
failure "You have chosen to create a project using ${lang_name}," \
"however, no type of ${lang_name} project can be initialized" \
"because no project template files could be found." \
"Please add at least one project type directory under" \
"the '${lang_id}' folder.";
fi

# Either prompt for a selection or automatically pick the
# only available project type
if (( n_ptypes > 1 )); then
FORM_QUESTION_ID="project.type";
logI "";
logI "Select the type of $lang_name project to be created:";
logI "Select the type of ${lang_name} project to be created:";
read_user_input_selection "${project_type_names[@]}";
local selected_name=${project_type_names[USER_INPUT_ENTERED_INDEX]};
local selected_dir=${project_type_dirs[USER_INPUT_ENTERED_INDEX]};
Expand Down

0 comments on commit 8c372cc

Please sign in to comment.