Skip to content

Commit

Permalink
Add make help for Makefile
Browse files Browse the repository at this point in the history
Add Help information for user in make command line.

Change-Id: Ic0a5ec5949dcc6462896721dfc1a482790d241af
Signed-off-by: Haitao Yue <hightall@me.com>
  • Loading branch information
hightall committed Jan 16, 2017
1 parent 271038d commit c8672b5
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
GREEN := $(shell tput -Txterm setaf 2)
WHITE := $(shell tput -Txterm setaf 7)
YELLOW := $(shell tput -Txterm setaf 3)
RESET := $(shell tput -Txterm sgr0)

.PHONY: \
all \
check \
Expand All @@ -10,30 +15,46 @@

all: check

check:
check: ##@Code Check code format
tox

clean:
clean: ##@Code Clean tox result
rm -rf .tox

# Use like "make log service=dashboard"
log:
log: ##@Log tail special service log, Use like "make log service=dashboard"
docker-compose logs -f ${service} --tail=100

logs:
docker-compose logs -f --tail=100

# Use like "make redeploy service=dashboard"
redeploy:
redeploy: ##@Service Redeploy single service, Use like "make redeploy service=dashboard"
bash scripts/redeploy.sh ${service}

start:
start: ##@Service Start service
bash scripts/start.sh

stop:
stop: ##@Service Stop service
bash scripts/stop.sh

restart: stop start
restart: ##@Service Restart service
stop start

setup:
setup: ##@Environment Setup dependency for service environment
bash scripts/setup.sh

HELP_FUN = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
print "usage: make [target]\n\n"; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; }

help: ##@other Show this help.
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)

0 comments on commit c8672b5

Please sign in to comment.