Skip to content

Commit 0749133

Browse files
committed
Makefile: refactor add docs and add command line help target
1 parent 2d054d5 commit 0749133

1 file changed

Lines changed: 29 additions & 22 deletions

File tree

Makefile

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,53 @@ define check_command
1111
}
1212
endef
1313

14-
all : check_rake
14+
# For colors
15+
ifneq ($(shell tty -s),)
16+
CYAN := $(shell tput setaf 6)
17+
RESET := $(shell tput sgr0)
18+
else
19+
CYAN :=
20+
RESET :=
21+
endif
22+
23+
.PHONY: all test clean check checkinstall checkupdate composecheck composetest check_rake check_docker_compose check_pre_commit help
24+
.DEFAULT_GOAL := all
25+
26+
all: check_rake ## build all targets, install (locally) in-repo
1527
$(RAKE)
16-
.PHONY : all
1728

18-
test : check_rake all
29+
test: check_rake all ## build and run all mruby tests
1930
$(RAKE) test
20-
.PHONY : test
2131

22-
clean : check_rake
32+
clean: check_rake ## clean all built and in-repo installed artifacts
2333
$(RAKE) clean
24-
.PHONY : clean
2534

26-
check : check_pre_commit
35+
check: check_pre_commit ## run all pre-commit hooks against all files
2736
$(PRE_COMMIT) run --all-files
28-
.PHONY : check
2937

30-
checkinstall : check_pre_commit
38+
checkinstall: check_pre_commit ## install the pre-commit hooks
3139
$(PRE_COMMIT) install
32-
.PHONY : checkinstall
3340

34-
checkupdate : check_pre_commit
41+
checkupdate: check_pre_commit ## check the pre-commit hooks for updates
3542
$(PRE_COMMIT) autoupdate
36-
.PHONY : checkupdate
3743

38-
composecheck : check_docker_compose check_pre_commit
44+
composecheck: check_docker_compose check_pre_commit ## run all pre-commit hooks against all files with docker-compose
3945
$(DOCKER_COMPOSE) -p mruby run test $(PRE_COMMIT) run --all-files
40-
.PHONY : composecheck
4146

42-
composetest : check_docker_compose
47+
composetest: check_docker_compose ## build and run all mruby tests with docker-compose
4348
$(DOCKER_COMPOSE) -p mruby run test
44-
.PHONY : composetest
4549

46-
check_rake:
50+
check_rake: ## check if Rake is installed
4751
$(call check_command, $(RAKE))
48-
.PHONY : check_rake
4952

50-
check_docker_compose:
53+
check_docker_compose: ## check if docker-compose is installed
5154
$(call check_command, $(DOCKER_COMPOSE))
52-
.PHONY : check_docker_compose
5355

54-
check_pre_commit:
56+
check_pre_commit: ## check if pre-commit is installed
5557
$(call check_command, $(PRE_COMMIT))
56-
.PHONY : check_pre_commit
58+
59+
help: ## display this help message
60+
@echo "Usage: make <target>"
61+
@echo
62+
@echo "Available targets:"
63+
@grep -E '^[a-z_-]+:.*##' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*## *"}; {printf " $(CYAN)%-20s$(RESET) %s\n", $$1, $$2}'

0 commit comments

Comments
 (0)