Skip to content

Commit 1604a5b

Browse files
refactor (Makefile):
- chmod +x - shebang - default goal is now the help target - mark targets as phony (avoid filename collisions) - error handling for install target - raise issue in todo for deprecated shellcheck call - help comments - help target (`make` / `make help`) - exclude requirements.txt (generated by Makefile)
1 parent 8d91260 commit 1604a5b

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# ETC
2+
requirements.txt
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]

Diff for: Makefile

100644100755
+39-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,53 @@
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+
114
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"
425

26+
# TODO: replace shellcheck with ruff or another linter (shellcheck doesn't work with python scripts)
27+
# * cf. commit: e6b3896
528
l: lint
6-
lint:
29+
lint: ## lint the plugin
730
shellcheck lima-plugin
831

932
r: requirements
10-
requirements:
33+
requirements: ## export the requirements.txt file
1134
poetry export -f requirements.txt --output requirements.txt
1235

1336
f: format
14-
format:
37+
format: ## format the plugin
1538
poetry run black lima-plugin
1639

1740
t: test
18-
test: format
41+
test: format ## test the plugin
1942
poetry run ./lima-plugin
2043

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

Comments
 (0)