-
Notifications
You must be signed in to change notification settings - Fork 2
/
task
executable file
·45 lines (37 loc) · 1.43 KB
/
task
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/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
}
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 "$?"