I've recently started using make as a task runner.
It started when I read Mina no Go Gengo (a book on Go) after I began learning Golang. (A revised 2nd edition has since come out!)
I've ended up writing pretty much everything in make lately, and here's a small trick I found useful along the way.
Depending on the task, you might have something that deploys or deletes resources.
For example, say you have a task called serious-task defined like this:
.PHONY: serious-task
serious-task:
something-serious
Running make serious-task here would directly execute something-serious, but depending on what the task does, you might want to prevent it from running by mistake.
While looking for a good way to handle this, I found the following question:
Based on this, I defined a task called confirmation like so:
.PHONY: confirmation
confirmation:
@read -p "Are you serious? [y/N]: " ans && [ $${ans:-N} = y ] || (echo "You're kidding me."; exit 1)
confirmation only exits successfully if it receives a y input.
$ make confirmation
Are you serious? [y/N]: y
$ make confirmation
Are you serious? [y/N]: N
You're kidding me.
make: *** [confirmation] Error 1
From here, all you need to do is call confirmation wherever appropriate:
.PHONY: serious-task
serious-task:
@$(MAKE) confirmation
something-serious
$ make serious-task
Are you serious? [y/N]: y
something-serious
$ make serious-task
Are you serious? [y/N]: N
You're kidding me.
Now something-serious only runs when you've explicitly entered y.