Files
git.taskfile.build/task.template
T
Janik von Rotz 2490a7329a feat(task): consolidate environment creation utilities into create-env
- Replace `create-odoo-env` and `create-nextcloud-env` with unified `create-env` function
- Support multiple environment types: odoo, nextcloud, and upgrade
- Update `list-env` to detect and display new environment types
- Adjust documentation and help table entries to reflect consolidated command
- Maintain existing code style and error handling patterns
2025-11-27 10:05:40 +01:00

85 lines
3.6 KiB
Bash
Executable File

#!/usr/bin/env bash
help-table() {
local cmd_width=24
local opt_width=18
local desc_width=50
local column="| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n"
printf "$column" "Command" "Option" "Description"
echo "|$(printf '%*s' $((cmd_width + 2)) '' | tr ' ' '-')|$(printf '%*s' $((opt_width + 2)) '' | tr ' ' '-')|$(printf '%*s' $((desc_width + 2)) '' | tr ' ' '-')|"
# Task
printf "$column" 'init-config-dir' '' 'Setup task file config dir.'
printf "$column" 'template-dotenv' '' 'Generate .env from .env.template.'
printf "$column" 'open-with-os' '' 'Open file or url with default application.'
printf "$column" 'open-url-with-delay' '[url][delay]' 'Open url after n seconds.'
# Files
printf "$column" 'ensure-directory' '[path]' 'Ensure directory path exists.'
printf "$column" 'create-symlink' '[source][target]' 'Remove existing file/directory and create symlink.'
printf "$column" 'create-symlink-files' '[source][target]' 'Create symlink for files in source pattern.'
# Python
printf "$column" 'activate-venv' '' 'Activate or initialize Python virtual env.'
# Environment
printf "$column" 'create-env' '[env][type]' 'Create env file of type nextcloud, odoo, upgrade.'
printf "$column" 'list-env' '' 'List env files.'
printf "$column" 'show-env' '[env]' 'Output content of the env file.'
printf "$column" 'copy-env' '[env][env]' 'Copy env file.'
printf "$column" 'edit-env' '[env]' 'Open env file in default editor.'
printf "$column" 'load-env' '[env]' 'Load and export env file.'
printf "$column" 'rename-env' '[env][env]' 'Rename env file.'
printf "$column" 'remove-env' '[env]' 'Remove environment config.'
printf "$column" 'backup-env-files' '[path]' 'Archive and copy env files to target location.'
printf "$column" 'restore-env-files' '[path]' 'Extract and copy env files from backup file.'
# LLM
printf "$column" 'commit-with-llm' '' 'Commit with llm generated commit message.'
printf "$column" 'update-with-llm' '[glob][prompt]' 'Feed files matching glob to LLM and apply changes.'
# Logging
printf "$column" 'log-warning' '' 'Colored output for warnings.'
# Git
printf "$column" 'update-submodule' '' 'Update git submodules.'
# Pass
printf "$column" 'save-dotenv-to-pass' '' 'Store content of .env in pass entry.'
printf "$column" 'load-dotenv-from-pass' '' 'Restore content to .env from pass entry.'
# KeePass
printf "$column" 'save-pass-to-keepass' '[pass][entry]' 'Store password to KeePass entry.'
printf "$column" 'get-pass-from-keepass' '[entry]' 'Get password from KeePass entry.'
printf "$column" 'save-dotenv-to-keepass' '' 'Store content of .env in KeePass entry.'
printf "$column" 'load-dotenv-from-keepass' '' 'Restore content to .env from KeePass entry.'
# Docker
printf "$column" 'login-docker' '[user][token]' 'Run Docker login and create docker config.'
printf "$column" 'build-image' '[output]' 'Build Docker image with buildx.'
}
help() {
echo
if [[ -n "$1" ]]; then
help-table | grep -i "$1" | column -t -s'|'
else
echo "task <command> [options]"
echo
echo "commands:"
echo
help-table
fi
echo
}
if [[ -d "$HOME/taskfile.build/bin" ]]; then
for file in "$HOME/taskfile.build/bin/"*; do
if [[ -f "$file" ]]; then
source "$file"
fi
done
fi
if declare -f "$1" > /dev/null; then
"$1" "${@:2}"
else
case "$1" in
*)
echo "Unknown command: $1"
exit 1
;;
esac
fi