#!/bin/bash set -e function help-table() { CMD_WIDTH=18 OPT_WIDTH=6 DESC_WIDTH=42 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 ' ' '-')|" printf "$COLUMN" "all" "" "Run all tasks." printf "$COLUMN" "build" "" "Build the 11ty website." printf "$COLUMN" "commit-with-llm" "" "Commit with llm generated commit message." printf "$COLUMN" "dev" "" "Run 11ty server." printf "$COLUMN" "help" "[grep]" "Show help for commands." printf "$COLUMN" "install" "" "Install node packages." printf "$COLUMN" "lint" "" "Lint code with prettier." printf "$COLUMN" "run-tests" "" "Test with shellcheck." printf "$COLUMN" "serve" "" "Serve the 11ty output folder." printf "$COLUMN" "version" "" "Show version of required tools." } # Import commands source ./bin/help source ./bin/commit-with-llm # Project commands function install() { pnpm install } function dev() { npx eleventy --serve } function lint() { pnpm exec prettier . --write } function run-tests() { echo "Test with shellcheck." shellcheck task } function build() { npx eleventy } function serve() { npx serve ./_site } function version() { echo "eleventy: $(npx eleventy --version)" } if declare -f "$1" > /dev/null; then "$1" "${@:2}" else case "$1" in all) install build ;; *) echo "Unknown command: $1" help exit 1 ;; esac fi