|
| 1 | +#!/usr/bin/make -f |
| 2 | + |
| 3 | +.DEFAULT_GOAL := help |
| 4 | + |
| 5 | +GREEN := $(shell tput -Txterm setaf 2) |
| 6 | +YELLOW := $(shell tput -Txterm setaf 3) |
| 7 | +WHITE := $(shell tput -Txterm setaf 7) |
| 8 | +CYAN := $(shell tput -Txterm setaf 6) |
| 9 | +RESET := $(shell tput -Txterm sgr0) |
| 10 | + |
| 11 | +.PHONY: all |
| 12 | +all: i install l lint r requirements f format t test ## run all targets |
| 13 | + |
1 | 14 | i: format install
|
2 |
| -install: format |
3 |
| - cp lima-plugin ~/Library/Application\ Support/xbar/plugins/lima-plugin.10s |
| 15 | +install: format ## install the plugin |
| 16 | + @if logname >/dev/null 2>&1; then \ |
| 17 | + logged_in_user=$$(logname); \ |
| 18 | + else \ |
| 19 | + logged_in_user=$$(whoami); \ |
| 20 | + fi; \ |
| 21 | + @if [ -d "$${logged_in_user}/Library/Application Support/xbar/plugins" ]; then \ |
| 22 | + mkdir -p "$${logged_in_user}/Library/Application Support/xbar/plugins"; \ |
| 23 | + fi; \ |
| 24 | + cp lima-plugin "$${logged_in_user}/Library/Application Support/xbar/plugins/lima-plugin.10s" |
4 | 25 |
|
| 26 | +# TODO: replace shellcheck with ruff or another linter (shellcheck doesn't work with python scripts) |
| 27 | +# * cf. commit: e6b3896 |
5 | 28 | l: lint
|
6 |
| -lint: |
| 29 | +lint: ## lint the plugin |
7 | 30 | shellcheck lima-plugin
|
8 | 31 |
|
9 | 32 | r: requirements
|
10 |
| -requirements: |
| 33 | +requirements: ## export the requirements.txt file |
11 | 34 | poetry export -f requirements.txt --output requirements.txt
|
12 | 35 |
|
13 | 36 | f: format
|
14 |
| -format: |
| 37 | +format: ## format the plugin |
15 | 38 | poetry run black lima-plugin
|
16 | 39 |
|
17 | 40 | t: test
|
18 |
| -test: format |
| 41 | +test: format ## test the plugin |
19 | 42 | poetry run ./lima-plugin
|
20 | 43 |
|
| 44 | +help: ## show this help |
| 45 | + @echo '' |
| 46 | + @echo 'Usage:' |
| 47 | + @echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}' |
| 48 | + @echo '' |
| 49 | + @echo 'Targets:' |
| 50 | + @awk 'BEGIN {FS = ":.*?## "} { \ |
| 51 | + if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \ |
| 52 | + else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \ |
| 53 | + }' $(MAKEFILE_LIST) |
0 commit comments