Files
git.taskfile.build/task.template
T
Janik von Rotz 7c6e6e300a feat: add update-template command to synchronize task.template with library.md
- Added `update-template` command that extracts rows from `library.md` and updates `task.template`
- Implemented logic to replace existing rows in `task.template` with current rows from `library.md`
- Added `update-template` to help-table for documentation and discoverability
- Updated `library.md` and `task.template` to include new `update-template` command
- Removed outdated prompt script that was no longer needed
- Ensured all rows from `library.md` are properly synchronized with `task.template`
2026-02-10 12:23:07 +01:00

130 lines
5.3 KiB
Bash

#!/usr/bin/env bash
set -e
help-table() {
local -a rows
local max_cmd=7 max_opt=6 max_desc=11
rows+=("Command|Option|Description")
rows+=("clone-taskfile||Clone the taskfile.build repo.")
rows+=("init-project||Setup a taskfile project in the current directory.")
rows+=("init-dotenv-dir||Setup task dotenv dir.")
rows+=("template-dotenv||Generate .env from .env.template.")
rows+=("open-with-os||Open file or url with default application.")
rows+=("open-url-with-delay|[url][delay]|Open url after n seconds.")
rows+=("show-dotenv-setup||Show info about the dotenv setup.")
rows+=("ensure-directory|[path]|Ensure directory path exists.")
rows+=("create-symlink|[target][source]|Remove existing file/directory and create symlink.")
rows+=("create-symlink-files|[target][source]|Create symlink for files in source pattern.")
rows+=("activate-venv||Activate or initialize Python virtual env.")
rows+=("remove-venv||Remove the Python virtual env.")
rows+=("create-dotenv|[env][type]|Create .env file of type nextcloud, odoo, upgrade.")
rows+=("list-dotenv||List dotenv files.")
rows+=("show-dotenv|[env]|Output content of the .env file.")
rows+=("copy-dotenv|[env][env]|dotenv dotenv file.")
rows+=("edit-dotenv|[env]|Open .env file in default editor.")
rows+=("load-dotenv|[env]|Load and export .env file.")
rows+=("rename-dotenv|[env][env]|Rename .env file.")
rows+=("remove-dotenv|[env]|Remove .env file.")
rows+=("backup-dotenv-files|[path]|Archive and copy .env files to target location.")
rows+=("restore-dotenv-files|[path]|Extract and copy .env files from backup file.")
rows+=("commit-with-llm||Commit with llm generated commit message.")
rows+=("update-with-llm|[glob][prompt]|Feed files matching glob to LLM and apply changes.")
rows+=("log-error||Colored output for errors.")
rows+=("log-success||Colored output for success.")
rows+=("log-warning||Colored output for warnings.")
rows+=("commit-git-folder|[message][path]|Commit all changes in git folders in path.")
rows+=("clean-git-folder||Clean git folder.")
rows+=("ls-git-folder|[path]|Space separated list of git folders in path.")
rows+=("push-git-folder||Push all git folders in path.")
rows+=("reset-git-folder||Abort, rebase and reset git folder.")
rows+=("stage-git-folder|[path]|Stage all files in git folders in path.")
rows+=("status-git-folder|[path]|Show status of git folders in path.")
rows+=("update-submodule||Update git submodules.")
rows+=("save-dotenv-to-pass|[file]|Store content of .env in pass entry.")
rows+=("load-dotenv-from-pass|[file]|Restore content to .env from pass entry.")
rows+=("save-pass-to-keepass|[pass][entry]|Store password to KeePass entry.")
rows+=("get-pass-from-keepass|[entry]|Get password from KeePass entry.")
rows+=("save-dotenv-to-keepass|[file]|Store content of .env in KeePass entry.")
rows+=("load-dotenv-from-keepass|[file]|Restore content to .env from KeePass entry.")
rows+=("save-kubeconfig-to-pass|[ctx]|Save kubeconfig file in pass.")
rows+=("save-kubeconfig-to-keepass|[ctx]|Save kubeconfig file in KeePass.")
rows+=("load-kubeconfig-from-pass|[ctx]|Load kubeconfig file from pass.")
rows+=("load-kubeconfig-from-keepass|[ctx]|Load kubeconfig file from KeePass.")
rows+=("login-docker|[user][token]|Run Docker login and create docker config.")
rows+=("build-image|[output]|Build Docker image with buildx.")
rows+=("install-ansible-build-scripts|[role]|Install scripts of the specified Ansbile role.")
for row in "${rows[@]}"; do
IFS='|' read -r cmd opt desc <<< "$row"
(( ${#cmd} > max_cmd )) && max_cmd=${#cmd}
(( ${#opt} > max_opt )) && max_opt=${#opt}
(( ${#desc} > max_desc )) && max_desc=${#desc}
done
printf '| %-*s | %-*s | %-*s |\n' \
"$max_cmd" "Command" \
"$max_opt" "Option" \
"$max_desc" "Description"
printf '|-%*s-|-%*s-|-%*s-|\n' \
"$max_cmd" "$(printf '%*s' "$max_cmd" '' | tr ' ' '-')" \
"$max_opt" "$(printf '%*s' "$max_opt" '' | tr ' ' '-')" \
"$max_desc" "$(printf '%*s' "$max_desc" '' | tr ' ' '-')"
for row in "${rows[@]:1}"; do
IFS='|' read -r cmd opt desc <<< "$row"
printf '| %-*s | %-*s | %-*s |\n' \
"$max_cmd" "$cmd" \
"$max_opt" "$opt" \
"$max_desc" "$desc"
done
}
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 [[ "$1" == *","* ]]; then
# Split comma-separated commands
IFS=',' read -ra COMMANDS <<< "$1"
for cmd in "${COMMANDS[@]}"; do
# Trim whitespace
cmd=$(echo "$cmd" | xargs)
if declare -f "$cmd" > /dev/null; then
"$cmd"
else
echo "Unknown command: $cmd"
help
exit 1
fi
done
elif declare -f "$1" > /dev/null; then
"$1" "${@:2}"
else
case "$1" in
*)
echo "Unknown command: $1"
exit 1
;;
esac
fi