Use two columns for three header entries
This commit is contained in:
@@ -387,33 +387,51 @@ interactive_header() {
|
|||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "Available Modules:"
|
echo "Available Modules:"
|
||||||
if [ ${#ALL_MODULES[@]} -gt 8 ]; then
|
# Determine if we need two columns
|
||||||
# Print in two columns
|
if [[ ${#ALL_MODULES[@]} -gt 8 ]]; then
|
||||||
for ((i=0; i<${#ALL_MODULES[@]}; i++)); do
|
# Calculate the number of elements in each column
|
||||||
printf "%d. %s\t" $((i+1)) "${ALL_MODULES[i]}"
|
num_columns=$(( (${#ALL_MODULES[@]} + 1) / 2 ))
|
||||||
if [ $((i % 2)) -eq 1 ]; then
|
|
||||||
echo
|
# Determine the maximum width of the first column
|
||||||
fi
|
max_width=0
|
||||||
done
|
for ((i=0; i<num_columns; i++)); do
|
||||||
|
# Check if the item exists
|
||||||
|
if [[ -n "${ALL_MODULES[i]}" ]]; then
|
||||||
|
item_length=${#ALL_MODULES[i]}
|
||||||
|
if [[ $item_length -gt $max_width ]]; then
|
||||||
|
max_width=$item_length
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Print in two columns
|
||||||
|
for ((i=0; i<num_columns; i++)); do
|
||||||
|
# Print the first column
|
||||||
|
if [[ -n "${ALL_MODULES[i]}" ]]; then
|
||||||
|
printf "%d. %-${max_width}s" $((i+1)) "${ALL_MODULES[i]}"
|
||||||
|
else
|
||||||
|
printf "%${max_width}s" ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Print the second column if it exists
|
||||||
|
if [[ $((i + num_columns)) -lt ${#ALL_MODULES[@]} ]]; then
|
||||||
|
printf "\t%d. %s\n" $((i + num_columns + 1)) "${ALL_MODULES[i + num_columns]}"
|
||||||
|
else
|
||||||
|
# Print a newline if no second column item
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
done
|
||||||
else
|
else
|
||||||
# Print in a single column
|
# Print in a single column
|
||||||
for ((i=0; i<${#ALL_MODULES[@]}; i++)); do
|
for ((i=0; i<${#ALL_MODULES[@]}; i++)); do
|
||||||
printf "%d. %s\n" $((i+1)) "${ALL_MODULES[i]}"
|
printf "%d. %s\n" $((i+1)) "${ALL_MODULES[i]}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
# # Print the array with item numbers in two columns
|
|
||||||
# for ((i=0; i<${#ALL_MODULES[@]}; i++)); do
|
|
||||||
# printf "%d\t%s\n" $((i+1)) "${ALL_MODULES[i]}"
|
|
||||||
# done | column -t -s $'\t'
|
|
||||||
# echo ""
|
|
||||||
|
|
||||||
echo "Available Submodules:"
|
echo "Available Submodules:"
|
||||||
|
|
||||||
# Determine if we need two columns
|
# 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 ))
|
||||||
|
|
||||||
@@ -432,14 +450,14 @@ interactive_header() {
|
|||||||
# Print in two columns
|
# Print in two columns
|
||||||
for ((i=0; i<num_columns; i++)); do
|
for ((i=0; i<num_columns; i++)); do
|
||||||
# Print the first column
|
# Print the first column
|
||||||
if [ -n "${ALL_SUBMODULES[i]}" ]; then
|
if [[ -n "${ALL_SUBMODULES[i]}" ]]; then
|
||||||
printf "%d. %-${max_width}s" $((i+1)) "${ALL_SUBMODULES[i]}"
|
printf "%d. %-${max_width}s" $((i+1)) "${ALL_SUBMODULES[i]}"
|
||||||
else
|
else
|
||||||
printf "%${max_width}s" ""
|
printf "%${max_width}s" ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print the second column if it exists
|
# Print the second column if it exists
|
||||||
if [ $((i + num_columns)) -lt ${#ALL_SUBMODULES[@]} ]; then
|
if [[ $((i + num_columns)) -lt ${#ALL_SUBMODULES[@]} ]]; then
|
||||||
printf "\t%d. %s\n" $((i + num_columns + 1)) "${ALL_SUBMODULES[i + num_columns]}"
|
printf "\t%d. %s\n" $((i + num_columns + 1)) "${ALL_SUBMODULES[i + num_columns]}"
|
||||||
else
|
else
|
||||||
# Print a newline if no second column item
|
# Print a newline if no second column item
|
||||||
@@ -453,58 +471,8 @@ 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 ""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# if [ ${#ALL_SUBMODULES[@]} -gt 8 ]; then
|
|
||||||
# # Print in two columns
|
|
||||||
# for ((i=0; i<${#ALL_SUBMODULES[@]}; i++)); do
|
|
||||||
# printf "%d. %s\t" $((i+1)) "${ALL_SUBMODULES[i]}"
|
|
||||||
# if [ $((i % 2)) -eq 1 ]; then
|
|
||||||
# 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 ""
|
|
||||||
# for i in "${!ALL_SUBMODULES[@]}"; do
|
|
||||||
# printf "%d. %s\n" "$((i+1))" "${ALL_SUBMODULES[i]}"
|
|
||||||
# done
|
|
||||||
# echo ""
|
|
||||||
|
|
||||||
# Gather and list projects from SCANS_DIR
|
# Gather and list projects from SCANS_DIR
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
projects=("$SCANS_DIR"/*/)
|
projects=("$SCANS_DIR"/*/)
|
||||||
@@ -517,12 +485,48 @@ interactive_header() {
|
|||||||
echo "Available Projects:"
|
echo "Available Projects:"
|
||||||
projects=("${projects[@]%/}") # strip comma first!
|
projects=("${projects[@]%/}") # strip comma first!
|
||||||
projects=("${projects[@]##*/}")
|
projects=("${projects[@]##*/}")
|
||||||
for i in "${!projects[@]}"; do
|
|
||||||
printf "%d. %s\n" "$((i+1))" "${projects[i]}"
|
# Determine if we need two columns
|
||||||
done
|
if [[ ${#projects[@]} -gt 8 ]]; then
|
||||||
fi
|
# Calculate the number of elements in each column
|
||||||
echo ""
|
num_columns=$(( (${#projects[@]} + 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 "${projects[i]}" ]]; then
|
||||||
|
item_length=${#projects[i]}
|
||||||
|
if [[ $item_length -gt $max_width ]]; then
|
||||||
|
max_width=$item_length
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Print in two columns
|
||||||
|
for ((i=0; i<num_columns; i++)); do
|
||||||
|
# Print the first column
|
||||||
|
if [[ -n "${projects[i]}" ]]; then
|
||||||
|
printf "%d. %-${max_width}s" $((i+1)) "${projects[i]}"
|
||||||
|
else
|
||||||
|
printf "%${max_width}s" ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Print the second column if it exists
|
||||||
|
if [[ $((i + num_columns)) -lt ${#projects[@]} ]]; then
|
||||||
|
printf "\t%d. %s\n" $((i + num_columns + 1)) "${projects[i + num_columns]}"
|
||||||
|
else
|
||||||
|
# Print a newline if no second column item
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
# Print in a single column
|
||||||
|
for ((i=0; i<${#projects[@]}; i++)); do
|
||||||
|
printf "%d. %s\n" $((i+1)) "${projects[i]}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
# Let user choose or add project(s)
|
# Let user choose or add project(s)
|
||||||
if [[ -z ${PROJECTS[*]} ]]; then
|
if [[ -z ${PROJECTS[*]} ]]; then
|
||||||
num=$((${#projects[@]}))
|
num=$((${#projects[@]}))
|
||||||
|
|||||||
Reference in New Issue
Block a user