viv/task

49 lines
1.4 KiB
Text
Raw Permalink Normal View History

2023-11-30 17:03:17 -06:00
#!/usr/bin/env bash
# VERSION = $(git describe --tags --always --dirty=-dev | sed 's/^v//g')
function task:venv {
: "setup up pdm venv"
pdm install
}
function task:dev-install {
: "symlink development version"
mkdir -p ~/.local/share/viv
mkdir -p ~/.local/bin
ln -sf "$(pwd)/src/viv/viv.py" ~/.local/share/viv/viv.py
ln -sf ~/.local/share/viv/viv.py ~/.local/bin/viv
2023-11-30 17:03:17 -06:00
}
function task:_black {
: "generate black example shim"
rm -f examples/black
viv shim black -y -s -f -o examples/black
}
function task:clean {
: "clean build artifacts"
rm -rf build dist
}
function task:examples {
: "run examples to generate vivenvs"
examples="cli sys_path exe_specific frozen_import named_env scrape"
for f in $examples; do
python "examples/$f.py"
done
}
function task:_help-logo {
FORCE_COLOR=1 viv --help | yartsu -t 'viv --help' -w 70 -o assets/viv-help.svg
}
# ---- do-task boilerplate ----
function task:help {
: "Show this help"
echo "do:";w=$(("$(compgen -A function | wc -L)" - 3));while read -r name; do [[ ! $name =~ ^task:_ ]] && [[ $name =~ ^task: ]] && paste <(printf '\033[1;32m%*s\033[0m\n' "$w" "${name#task:}") <(type "$name" | sed -nEe 's/^[[:space:]]*: ?"(.*)";/\1/p'); done < <(compgen -A function)
}
while read -r name; do [[ $name == "task:$1" ]] && { shift; task="$name"; }; done < <(compgen -A function)
[[ -n "$1" && -z "$task" ]] && printf "\033[1;31m%s\033\0[m is not a task\n" "$1"
"${task:-task:help}" "$@" && exit "$?"