Try printing modules in two columns
This commit is contained in:
@@ -411,15 +411,38 @@ interactive_header() {
|
|||||||
# echo ""
|
# echo ""
|
||||||
|
|
||||||
echo "Available Submodules:"
|
echo "Available Submodules:"
|
||||||
|
|
||||||
|
# Determine if we need two columns
|
||||||
if [ ${#ALL_SUBMODULES[@]} -gt 8 ]; then
|
if [ ${#ALL_SUBMODULES[@]} -gt 8 ]; then
|
||||||
# Calculate the number of elements in each column
|
# Calculate the number of elements in each column
|
||||||
num_columns=$(( (${#ALL_SUBMODULES[@]} + 1) / 2 ))
|
num_columns=$(( (${#ALL_SUBMODULES[@]} + 1) / 2 ))
|
||||||
|
|
||||||
|
# Determine the maximum width of the first column
|
||||||
|
max_width=0
|
||||||
|
for ((i=0; i<num_columns; i++)); do
|
||||||
|
# Check if the item exists
|
||||||
|
if [[ -n "${ALL_SUBMODULES[i]}" ]]; then
|
||||||
|
item_length=${#ALL_SUBMODULES[i]}
|
||||||
|
if [[ $item_length -gt $max_width ]]; then
|
||||||
|
max_width=$item_length
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Print in two columns
|
# Print in two columns
|
||||||
for ((i=0; i<num_columns; i++)); do
|
for ((i=0; i<num_columns; i++)); do
|
||||||
printf "%d. %s" $((i+1)) "${ALL_SUBMODULES[i]}"
|
# Print the first column
|
||||||
if [ $((i + num_columns)) -lt ${#ALL_SUBMODULES[@]} ]; then
|
if [ -n "${ALL_SUBMODULES[i]}" ]; then
|
||||||
printf "\t\t\t%d. %s\n" $((i + num_columns + 1)) "${ALL_SUBMODULES[i + num_columns]}"
|
printf "%d. %-${max_width}s" $((i+1)) "${ALL_SUBMODULES[i]}"
|
||||||
else
|
else
|
||||||
|
printf "%${max_width}s" ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Print the second column if it exists
|
||||||
|
if [ $((i + num_columns)) -lt ${#ALL_SUBMODULES[@]} ]; then
|
||||||
|
printf "\t%d. %s\n" $((i + num_columns + 1)) "${ALL_SUBMODULES[i + num_columns]}"
|
||||||
|
else
|
||||||
|
# Print a newline if no second column item
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -430,6 +453,25 @@ interactive_header() {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
# if [ ${#ALL_SUBMODULES[@]} -gt 8 ]; then
|
||||||
|
# # Calculate the number of elements in each column
|
||||||
|
# num_columns=$(( (${#ALL_SUBMODULES[@]} + 1) / 2 ))
|
||||||
|
# # Print in two columns
|
||||||
|
# for ((i=0; i<num_columns; i++)); do
|
||||||
|
# printf "%d. %s" $((i+1)) "${ALL_SUBMODULES[i]}"
|
||||||
|
# if [ $((i + num_columns)) -lt ${#ALL_SUBMODULES[@]} ]; then
|
||||||
|
# printf "\t\t%d. %s\n" $((i + num_columns + 1)) "${ALL_SUBMODULES[i + num_columns]}"
|
||||||
|
# else
|
||||||
|
# echo
|
||||||
|
# fi
|
||||||
|
# done
|
||||||
|
# else
|
||||||
|
# # Print in a single column
|
||||||
|
# for ((i=0; i<${#ALL_SUBMODULES[@]}; i++)); do
|
||||||
|
# printf "%d. %s\n" $((i+1)) "${ALL_SUBMODULES[i]}"
|
||||||
|
# done
|
||||||
|
# fi
|
||||||
|
# echo ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user