- Increase `name_width` from 20 to 30 for better environment name visibility - Rename `file_width` to `type_width` for clarity and consistency - Update table formatting logic to use the corrected variable names - Maintain existing code style and output format
28 lines
838 B
Bash
Executable File
28 lines
838 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
list-env() {
|
|
TASK_CONFIG_DIR=${TASK_CONFIG_DIR:="$HOME/.config/taskfile.build"}
|
|
|
|
# Define column widths
|
|
local name_width=30
|
|
local type_width=10
|
|
|
|
# Print table header
|
|
printf "| %-${name_width}s | %-${type_width}s |\n" "Name" "Type"
|
|
echo "|$(printf '%*s' $((name_width + 2)) '' | tr ' ' '-')|$(printf '%*s' $((type_width + 2)) '' | tr ' ' '-')|"
|
|
|
|
for env_file in "$TASK_CONFIG_DIR"/.env.*; do
|
|
if [[ -f "$env_file" ]]; then
|
|
local env_name="${env_file##*/}"
|
|
env_name="${env_name#.env.}"
|
|
|
|
local env_type="Odoo"
|
|
if grep -q "NEXTCLOUD" "$env_file"; then
|
|
env_type="Nextcloud"
|
|
fi
|
|
|
|
printf "| %-${name_width}s | %-${type_width}s |\n" "$env_name" "$env_type"
|
|
fi
|
|
done
|
|
}
|