Skip to content

Commit 023121f

Browse files
authored
feat(dev): emit descriptions for commands in help (#2678)
1 parent 1d4331c commit 023121f

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

Makefile

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
default:
1+
help:
22
@echo "Call a specific subcommand:"
33
@echo
4-
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null\
5-
| awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}'\
6-
| sort\
7-
| grep -E -v -e '^[^[:alnum:]]' -e '^$@$$'
4+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
5+
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
86
@echo
9-
@exit 1
7+
8+
default: help
109

1110
.state/docker-build-web: Dockerfile dev-requirements.txt base-requirements.txt
1211
# Build web container for this project
@@ -29,30 +28,29 @@ default:
2928
# Mark the state so we don't rebuild this needlessly.
3029
mkdir -p .state && touch .state/db-initialized
3130

32-
serve: .state/db-initialized
31+
serve: .state/db-initialized ## Start the application
3332
docker compose up --remove-orphans
3433

35-
migrations: .state/db-initialized
36-
# Run Django makemigrations
34+
migrations: .state/db-initialized ## Generate migrations from models
3735
docker compose run --rm web ./manage.py makemigrations
3836

39-
migrate: .state/docker-build-web
40-
# Run Django migrate
37+
migrate: .state/docker-build-web ## Run Django migrate
4138
docker compose run --rm web ./manage.py migrate
4239

43-
manage: .state/db-initialized
44-
# Run Django manage to accept arbitrary arguments
40+
manage: .state/db-initialized ## Run Django manage to accept arbitrary arguments
4541
docker compose run --rm web ./manage.py $(filter-out $@,$(MAKECMDGOALS))
4642

47-
shell: .state/db-initialized
43+
shell: .state/db-initialized ## Open Django interactive shell
4844
docker compose run --rm web ./manage.py shell
4945

50-
clean:
46+
clean: ## Clean up the environment
5147
docker compose down -v
5248
rm -f .state/docker-build-web .state/db-initialized .state/db-migrated
5349

54-
test: .state/db-initialized
50+
test: .state/db-initialized ## Run tests
5551
docker compose run --rm web ./manage.py test
5652

57-
docker_shell: .state/db-initialized
53+
docker_shell: .state/db-initialized ## Open a bash shell in the web container
5854
docker compose run --rm web /bin/bash
55+
56+
.PHONY: help serve migrations migrate manage shell clean test docker_shell

0 commit comments

Comments
 (0)