Files
git.taskfile.build/bin/list-dotenv
T
Janik von Rotz b94484305d feat: rename list-prompt to list-prompts and improve script formatting
- Renamed `bin/list-prompt` to `bin/list-prompts` and updated function name accordingly
- Updated references to `list-prompts` in `library.md`, `task.template`, and `usage.md`
- Added shebang and blank lines for consistency in `create-prompt`, `install-ansible-build-scripts`, and `list-dotenv` scripts
- Fixed table formatting in `usage.md` to use consistent column alignment
2026-02-16 13:59:19 +01:00

68 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
list-dotenv() {
TASK_DOTENV_DIR=${TASK_DOTENV_DIR:="$HOME/.config/taskfile.build"}
# Define column widths
local name_width=30
local type_width=10
local path_width=40 # Adjust as needed
# Print table header
printf "| %-${name_width}s | %-${type_width}s | %-${path_width}s |\n" "Name" "Type" "Path"
echo "|$(printf '%*s' $((name_width + 2)) '' | tr ' ' '-')|$(printf '%*s' $((type_width + 2)) '' | tr ' ' '-')|$(printf '%*s' $((path_width + 2)) '' | tr ' ' '-')|"
relative-path() {
local target="$1"
local base="$2"
if command -v realpath >/dev/null 2>&1; then
realpath --relative-to="$base" "$target" 2>/dev/null || echo "$target"
else
if [[ "$target" == "$base"/* ]]; then
echo "${target#$base/}"
else
echo "$target"
fi
fi
}
# Process files in TASK_DOTENV_DIR
for env_file in "$TASK_DOTENV_DIR"/.env.*; do
if [[ -f "$env_file" ]]; then
local env_name="${env_file##*/}"
env_name="${env_name#.env.}"
local env_type="odoo"
if [[ "$env_name" == "template" ]]; then
env_type="template"
elif grep -q "NEXTCLOUD" "$env_file"; then
env_type="nextcloud"
elif grep -q "ODOO_CONTAINER" "$env_file"; then
env_type="upgrade"
fi
local rel_path
rel_path=$(relative-path "$env_file" "$PWD")
printf "| %-${name_width}s | %-${type_width}s | %-${path_width}s |\n" "$env_name" "$env_type" "$rel_path"
fi
done
# Process files in current directory (PWD)
for env_file in .env.*; do
if [[ -f "$env_file" ]]; then
local env_name="${env_file##*/}"
env_name="${env_name#.env.}"
local env_type="project"
if [[ "$env_name" == "template" ]]; then
env_type="template"
fi
local rel_path
rel_path=$(relative-path "$env_file" "$PWD")
printf "| %-${name_width}s | %-${type_width}s | %-${path_width}s |\n" "$env_name" "$env_type" "$rel_path"
fi
done
}