diff --git a/.task.cfg.mk b/.task.cfg.mk deleted file mode 100644 index ea34919..0000000 --- a/.task.cfg.mk +++ /dev/null @@ -1,6 +0,0 @@ -USAGE={a.bold}{a.cyan} viv tasks{a.end}:\n -PHONIFY=1 -HELP_SEP={a.b_blue}>>>{a.end} - --include .task.mk -$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v23.1.2/task.mk -o .task.mk) diff --git a/Makefile b/Makefile deleted file mode 100644 index c7a3768..0000000 --- a/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -VERSION ?= $(shell git describe --tags --always --dirty=-dev | sed 's/^v//g') - -venv: ## generate environment - pdm install - -assets/viv-help.svg: - FORCE_COLOR=1 viv --help | yartsu -t 'viv --help' -w 70 -o $@ - -.PHONY: dev-install -dev-install: - ln -sf $(PWD)/src/viv/viv.py ~/.local/share/viv/viv.py - -examples/black: .FORCE - rm -f $@ - viv shim black -y -s -f -o $@ - -clean: ## remove build artifacts - rm -rf build dist - -EXAMPLES = cli.py sys_path.py exe_specific.py frozen_import.py named_env.py scrape.py -generate-example-vivens: ## - for f in $(EXAMPLES); \ - do python examples/$$f; done - - -.FORCE: -.PHONY: .FORCE --include .task.cfg.mk diff --git a/task b/task new file mode 100755 index 0000000..2fbba76 --- /dev/null +++ b/task @@ -0,0 +1,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" + ln -sf "$(PWD)/src/viv/viv.py" ~/.local/share/viv/viv.py +} + +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 "$?"