#!/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-dotenv-dir' '' 'Setup task dotenv 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.' printf "$column" 'remove-venv' '' 'Remove the 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" 'commit-git-folder' '[message][path]' 'Commit all changes in git folders in path.' printf "$column" 'clean-git-folder' '' 'Clean git folder.' printf "$column" 'ls-git-folder' '[path]' 'Space separated list of git folders in path.' printf "$column" 'push-git-folder' '' 'Push all git folders in path.' printf "$column" 'reset-git-folder' '' 'Abort, rebase and reset git folder.' printf "$column" 'stage-git-folder' '[path]' 'Stage all files in git folders in path.' printf "$column" 'status-git-folder' '[path]' 'Show status of git folders in path.' 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 [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