- Create `install-hugo`, `dev-hugo-site`, `build-hugo-site`, and `serve-hugo-site` scripts in `bin/` - Add Hugo configuration variables and command descriptions to `docs/library.md` - Update `task.template` with new Hugo help rows and section headers - Include short aliases (`ih`, `dhs`, `bhs`, `shs`) for Hugo commands
240 lines
12 KiB
Bash
240 lines
12 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+=("===Task===| | ")
|
|
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|<path>|Open file or url with default application.")
|
|
rows+=("open-url|<url>|Open url.")
|
|
rows+=("show-dotenv-setup||Show info about the dotenv setup.")
|
|
rows+=("setup-completion|[shell]|Show shell completion instructions.")
|
|
rows+=("list-taskfile-aliases||List all library command aliases.")
|
|
rows+=("===Files===| | ")
|
|
rows+=("ensure-directory|<path>|Ensure directory path exists.")
|
|
rows+=("create-symlink|<source><target>|Remove existing file/directory and create symlink.")
|
|
rows+=("create-symlink-files|<source><target>|Create symlink for files in source pattern.")
|
|
rows+=("copy-to-clipboard||Copy stdin to clipboard.")
|
|
rows+=("===Python===| | ")
|
|
rows+=("activate-venv||Activate or initialize Python virtual env.")
|
|
rows+=("remove-venv||Remove the Python virtual env.")
|
|
rows+=("===Jupyter===| | ")
|
|
rows+=("start-jupyter-lab|[env]|Start Jupyter Lab server.")
|
|
rows+=("install-jupyter-lab||Install Jupyter Lab and dependencies.")
|
|
rows+=("run-jupyter-notebook|<path>[env]|Execute notebook with papermill.")
|
|
rows+=("===Environment===| | ")
|
|
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>|Copy .env 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+=("===LLM===| | ")
|
|
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+=("update-changelog-with-llm|[num_lines]|Update CHANGELOG.md with changes from staged git diff using LLM.")
|
|
rows+=("===Prompt===| | ")
|
|
rows+=("init-prompt-log||Initialize prompt-log branch and worktree.")
|
|
rows+=("pull-prompt-log|[repo-path]|Pull prompt-log from origin.")
|
|
rows+=("create-prompt|<title>[repo-path]|Create prompt.md from template.")
|
|
rows+=("prompt-with-pi|[path]|Run pi with prompt.md.")
|
|
rows+=("commit-prompt|[repo-path]|Commit prompt.md to prompt-log branch.")
|
|
rows+=("list-prompts|[repo-path]|List prompts from prompt-log branch.")
|
|
rows+=("load-prompt|[repo-path]|Load prompt from prompt-log into prompt.md.")
|
|
rows+=("edit-prompt|[commit][repo-path]|Edit prompt directly in prompt-log worktree.")
|
|
rows+=("show-prompt|[commit][repo-path]|Show prompt content from prompt-log.")
|
|
rows+=("delete-prompt|[commit][repo-path]|Delete prompt from prompt-log.")
|
|
rows+=("convert-prompts-folder-to-prompt-log|[repo-path]|Convert prompts folder to prompt-log branch.")
|
|
rows+=("===Logging===| | ")
|
|
rows+=("log-error||Colored output for errors.")
|
|
rows+=("log-success||Colored output for success.")
|
|
rows+=("log-warning||Colored output for warnings.")
|
|
rows+=("===Git===| | ")
|
|
rows+=("add-git-folder|<url><branch><path>|Add git folder to .gitmodules.")
|
|
rows+=("add-git-merge|<remote><merge><path>|Add git merge ref to git folder in .gitmodules.")
|
|
rows+=("add-git-remote|<remote><url><path>|Add git remote to git folder.")
|
|
rows+=("merge-git-remote||Merge all remotes and refs defined in .gitmodules.")
|
|
rows+=("aggregate-git-folders|<path>|Run gitaggregate for the repos.yaml.")
|
|
rows+=("commit-git-folder|<path><message>|Commit all changes of git folders from .gitmodules file.")
|
|
rows+=("clean-git-folder|<path>|Clean git folder.")
|
|
rows+=("checkout-git-folder|<branch><path>|Checkout git commit from .gitmodules files.")
|
|
rows+=("clone-git-folder|<path>|Clone git folder from .gitmodules file.")
|
|
rows+=("download-git-folder|<path>|Download git folder from .gitmodules file.")
|
|
rows+=("find-git-folder|<path>|Find all .git folders in path.")
|
|
rows+=("generate-ssh-key||Generate ssh key pair.")
|
|
rows+=("list-git-folder|<path>|List path and url of git folders from .gitmodules file.")
|
|
rows+=("ls-git-folder|<path>|Space separated list of git folders from .gitmodules file.")
|
|
rows+=("pull-git-folder|<branch><path>|Pull all git folders from .gitmodules file.")
|
|
rows+=("pull-all-repos||Pull all git repos in $HOME.")
|
|
rows+=("switch-git-folder|<branch><path>|Switch branch for all git folders from .gitmodules file.")
|
|
rows+=("sync-git-folder|<branch><path>|Switch, stash and pull all git folders from .gitmodules file.")
|
|
rows+=("push-git-folder|<path>|Push all git folders from .gitmodules file.")
|
|
rows+=("remove-git-folder|<path>|Remove git folders in path from .gitmodules file.")
|
|
rows+=("reset-git-folder|<path>|Abort, rebase and reset git folders from .gitmodules file.")
|
|
rows+=("run-pre-commit|<path>|Run pre-commit in path.")
|
|
rows+=("stage-git-folder|<path>|Stage all files in git folders from .gitmodules file.")
|
|
rows+=("status-git-folder|<path>|Show status of git folders from .gitmodules file.")
|
|
rows+=("status-all-repos||Show status of all git repos in $HOME.")
|
|
rows+=("save-git-folder||Save commit refs to .gitmodules.")
|
|
rows+=("update-submodule||Update git submodules.")
|
|
rows+=("unshallow-git-folder||Fetch with unshallow and fix remote config.")
|
|
rows+=("===Pass===| | ")
|
|
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+=("===KeePass===| | ")
|
|
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+=("===Kubernetes===| | ")
|
|
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+=("===Docker===| | ")
|
|
rows+=("login-docker|[user][token]|Run Docker login and create docker config.")
|
|
rows+=("build-image|[output]|Build Docker image with buildx.")
|
|
rows+=("===Ansible===| | ")
|
|
rows+=("install-ansible-build-scripts|<role>|Install scripts of the specified Ansbile role.")
|
|
rows+=("===11ty===| | ")
|
|
rows+=("init-11ty-docs||Install 11ty with pnpm.")
|
|
rows+=("dev-11ty-docs||Run 11ty development server.")
|
|
rows+=("build-11ty-docs||Build the 11ty website.")
|
|
rows+=("serve-11ty-docs||Serve the 11ty output folder.")
|
|
rows+=("===Zensical===| | ")
|
|
rows+=("init-zensical-docs||Initialize Zensical documentation build dependencies.")
|
|
rows+=("dev-zensical-docs||Run Zensical development server.")
|
|
rows+=("build-zensical-docs||Build the Zensical documentation website.")
|
|
rows+=("serve-zensical-docs||Serve the Zensical documentation build folder.")
|
|
rows+=("===Vitepress===| | ")
|
|
rows+=("init-vitepress-docs||Install Vitepress build dependencies.")
|
|
rows+=("dev-vitepress-docs||Start Vitepress development server.")
|
|
rows+=("build-vitepress-docs||Create Vitepress build.")
|
|
rows+=("serve-vitepress-docs||Serve Vitepress build.")
|
|
rows+=("===Vuepress===| | ")
|
|
rows+=("init-vuepress-docs||Install Vuepress build dependencies.")
|
|
rows+=("dev-vuepress-docs||Start Vuepress development server.")
|
|
rows+=("build-vuepress-docs||Create Vuepress build.")
|
|
rows+=("serve-vuepress-docs||Serve Vuepress build.")
|
|
rows+=("===Hugo===| | ")
|
|
rows+=("install-hugo||Install Hugo from binary source.")
|
|
rows+=("dev-hugo-site|[url]|Start Hugo dev server.")
|
|
rows+=("build-hugo-site|[url]|Build with Hugo.")
|
|
rows+=("serve-hugo-site||Serve output from public folder.")
|
|
|
|
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 ' ' '-')"
|
|
|
|
local first_row=true
|
|
for row in "${rows[@]:1}"; do
|
|
IFS='|' read -r cmd opt desc <<< "$row"
|
|
if [[ "$cmd" =~ ^===.*===$ ]]; then
|
|
group_name="${cmd/===/}"
|
|
group_name="${group_name/===/}"
|
|
|
|
if [ "$first_row" = true ]; then
|
|
first_row=false
|
|
else
|
|
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 ' ' '-')"
|
|
fi
|
|
|
|
local left_pad=$(( (max_cmd - ${#group_name}) / 2 ))
|
|
local right_pad=$(( max_cmd - left_pad - ${#group_name} ))
|
|
printf '| %*s%s%*s | %*s | %*s |\n' \
|
|
"$left_pad" "" \
|
|
"$group_name" \
|
|
"$right_pad" "" \
|
|
"$max_opt" "" \
|
|
"$max_desc" ""
|
|
|
|
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 ' ' '-')"
|
|
else
|
|
first_row=false
|
|
printf '| %-*s | %-*s | %-*s |\n' \
|
|
"$max_cmd" "$cmd" \
|
|
"$max_opt" "$opt" \
|
|
"$max_desc" "$desc"
|
|
fi
|
|
done
|
|
}
|
|
|
|
help() {
|
|
local grep_pattern
|
|
echo
|
|
if [[ -n "$1" ]]; then
|
|
grep_pattern="$1"
|
|
help-table | grep -i "$grep_pattern" | 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" && -x "$file" ]]; then
|
|
# shellcheck disable=SC1090
|
|
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
|