mirror of
https://github.com/daylinmorgan/task.mk.git
synced 2024-11-09 19:13:14 -06:00
Compare commits
No commits in common. "77e76edd162830abb3252f257ff30d1109ae2a9a" and "8f875a13d1ee65497811df55bf2b21fc022e24b9" have entirely different histories.
77e76edd16
...
8f875a13d1
9 changed files with 45 additions and 24 deletions
13
Makefile
13
Makefile
|
@ -32,8 +32,7 @@ release: version-check
|
|||
$(call msg,Release Project)
|
||||
@./generate.py $(VERSION) > task.mk
|
||||
@sed -i 's/task.mk\/.*\/task.mk/task.mk\/v$(VERSION)\/task.mk/g' README.md
|
||||
@sed -i 's/task.mk\/.*\/task.mk/task.mk\/v$(VERSION)\/task.mk/g' docs/index.md
|
||||
@git add task.mk README.md docs/index.md
|
||||
@git add task.mk README.md
|
||||
@git commit -m "release: v$(VERSION)" --no-verify
|
||||
@git tag v$(VERSION)
|
||||
|
||||
|
@ -54,6 +53,7 @@ version-check:
|
|||
$(call tprint-sh,{a.green}VERSION LOOKS GOOD!{a.end});\
|
||||
fi
|
||||
|
||||
|
||||
## info | demonstrate usage of tprint
|
||||
.PHONY: task
|
||||
info:
|
||||
|
@ -62,18 +62,23 @@ info:
|
|||
$(call tprint,$(mlmsg))
|
||||
$(call tprint,{a.custom(fg=(148, 255, 15),bg=(103, 2, 15))}Custom Colors TOO!{a.end})
|
||||
|
||||
|
||||
task.mk: $(TEMPLATES) generate.py
|
||||
./generate.py $(VERSION) > task.mk
|
||||
|
||||
define USAGE
|
||||
{a.$(HEADER_STYLE)}usage:{a.end}\n make <recipe>\n
|
||||
{a.$(HEADER_STYLE)}usage:{a.end}
|
||||
make <recipe>
|
||||
|
||||
Turn your {a.style('`Makefile`','b_magenta')} into
|
||||
the {a.italic}{a.underline}task runner{a.end} you always needed.
|
||||
See the example output below.\n
|
||||
See the example output below.
|
||||
|
||||
endef
|
||||
|
||||
EPILOG = \nfor more info: gh.dayl.in/task.mk
|
||||
PRINT_VARS := VERSION
|
||||
|
||||
-include .task.mk
|
||||
.task.mk: $(TEMPLATES) generate.py
|
||||
$(call tprint,{a.b_yellow}re-jinjaing the local .task.mk{a.end})
|
||||
|
|
10
README.md
10
README.md
|
@ -4,12 +4,7 @@
|
|||
<p align="center">
|
||||
the task runner for GNU Make you've been missing
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://gh.dayl.in/task.mk">Documentation</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</br>
|
||||
|
||||
GNU make is an excellent build tool and the task runner we love to hate, but can't escape.
|
||||
|
@ -37,14 +32,14 @@ If someone tries to invoke `make help` it will download `.task.mk` for them.
|
|||
|
||||
```make
|
||||
-include .task.mk
|
||||
$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.19/task.mk -o .task.mk))
|
||||
$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.14/task.mk -o .task.mk))
|
||||
```
|
||||
|
||||
You might also consider making it a consistently downloaded dependency if you plan to use any of it's advanced feature set, by dropping the `$(MAKECMDGOALS)` check.
|
||||
|
||||
```make
|
||||
-include .task.mk
|
||||
$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.19/task.mk -o .task.mk)
|
||||
$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.14/task.mk -o .task.mk)
|
||||
```
|
||||
|
||||
For more info see the [documentation](https://gh.dayl.in/task.mk).
|
||||
|
@ -57,7 +52,6 @@ But I just want a basic help output, surely I don't need python for this... you
|
|||
|
||||
```make
|
||||
## h, help | show this help
|
||||
### additional text printed with the help
|
||||
.PHONY: help h
|
||||
help h: Makefile
|
||||
@awk -v fill=$(shell sed -n 's/^## \(.*\) | .*/\1/p' $< | wc -L)\
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
msgfmt = {a.style('==>','bold')} {a.style('$(1)','b_magenta')} {a.style('<==','bold')}
|
||||
msg = $(call tprint,$(call msgfmt ,$(1)))
|
||||
|
||||
|
||||
## check | get user confirmation or exit
|
||||
.PHONY: check
|
||||
check:
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
msgfmt = {a.style('==>','bold')} {a.style('$(1)','b_magenta')} {a.style('<==','bold')}
|
||||
msg = $(call tprint,$(call msgfmt ,$(1)))
|
||||
|
||||
### examples of task.mk features | args: --divider --align center --msg-style b_red
|
||||
define list_files_py
|
||||
from pathlib import Path
|
||||
|
@ -31,6 +34,14 @@ endef
|
|||
embedded-bash:
|
||||
$(call tbash,bash_script,bash multiline is probably working)
|
||||
|
||||
define mlmsg
|
||||
{a.b_yellow}
|
||||
It can even be multiline!{a.end}
|
||||
{a.style('and styles can be defined','red')}
|
||||
as python {a.bold}f-string{a.end} literals
|
||||
{a.end}
|
||||
endef
|
||||
|
||||
define USAGE
|
||||
{a.$(HEADER_STYLE)}usage:{a.end}
|
||||
make <recipe>
|
||||
|
|
|
@ -23,7 +23,7 @@ Current Features:
|
|||
Depends on `GNU Make`, obviously and `Python >=3.7`.
|
||||
|
||||
Wait python?!?!, I'm not `pip` installing some package just to parse my makefile.
|
||||
I agree, all you need is one file [`.task.mk`](https://github.com/daylinmorgan/task.mk/v22.9.19/task.mk).
|
||||
I agree, all you need is one file [`.task.mk`](https://github.com/daylinmorgan/task.mk/blob/main/task.mk).
|
||||
You can automagically include it with just two additional lines to your `Makefile` (and probably one to your `.gitignore`) and your good to go.
|
||||
|
||||
## Setup
|
||||
|
@ -33,14 +33,14 @@ If someone tries to invoke `make help` it will download `.task.mk` for them.
|
|||
|
||||
```make
|
||||
-include .task.mk
|
||||
$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.19/task.mk -o .task.mk))
|
||||
$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.14/task.mk -o .task.mk))
|
||||
```
|
||||
|
||||
You might also consider making it a consistently downloaded dependency if you plan to use any of it's advanced feature set, by dropping the `$(MAKECMDGOALS)` check.
|
||||
|
||||
```make
|
||||
-include .task.mk
|
||||
$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.19/task.mk -o .task.mk)
|
||||
$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.14/task.mk -o .task.mk)
|
||||
```
|
||||
|
||||
Alternatively, you can use the builtin rule `_update-task.mk` to update to the latest development version.
|
||||
|
|
|
@ -9,4 +9,4 @@ DIVIDER ?= ─
|
|||
HELP_SEP ?= │
|
||||
# python f-string literals
|
||||
EPILOG ?=
|
||||
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n
|
||||
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>
|
||||
|
|
|
@ -53,7 +53,7 @@ def fmt_goal(goal, msg, max_goal_len, argstr):
|
|||
msg_style = args.msg_style.strip() if args.msg_style else "$(MSG_STYLE)"
|
||||
return (
|
||||
ansi.style(f" {goal:>{max_goal_len}}", goal_style)
|
||||
+ f" $(HELP_SEP) "
|
||||
+ " $(HELP_SEP) "
|
||||
+ ansi.style(msg, msg_style)
|
||||
)
|
||||
|
||||
|
|
|
@ -2,9 +2,13 @@
|
|||
#% block name %#print_ansi#% endblock %#
|
||||
#% block script %#
|
||||
##- '$(ansi_py)' -##
|
||||
sep = f"$(HELP_SEP)"
|
||||
|
||||
codes_names = {getattr(ansi, attr): attr for attr in ansi.__dict__}
|
||||
for code in sorted(codes_names.keys(), key=lambda item: (len(item), item)):
|
||||
print(f"{codes_names[code]:>20} {sep} {code+'*****'+ansi.end} {sep} {repr(code)}")
|
||||
print(
|
||||
"{:>20} $(HELP_SEP) {} $(HELP_SEP) {}".format(
|
||||
codes_names[code], code + "******" + ansi.end, repr(code)
|
||||
)
|
||||
)
|
||||
|
||||
#% endblock %#
|
||||
|
|
13
task.mk
13
task.mk
|
@ -1,7 +1,7 @@
|
|||
# }> [github.com/daylinmorgan/task.mk] <{ #
|
||||
# Copyright (c) 2022 Daylin Morgan
|
||||
# MIT License
|
||||
# version: 22.9.19
|
||||
# version: v22.9.14-18-g1a018e2-dev
|
||||
#
|
||||
# task.mk should be included at the bottom of your Makefile with `-include .task.mk`
|
||||
# See below for the standard configuration options that should be set prior to including this file.
|
||||
|
@ -17,7 +17,7 @@ DIVIDER ?= ─
|
|||
HELP_SEP ?= │
|
||||
# python f-string literals
|
||||
EPILOG ?=
|
||||
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n
|
||||
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>
|
||||
# ---- [buitlin recipes] ---- #
|
||||
## h, help | show this help
|
||||
.PHONY: help h
|
||||
|
@ -112,7 +112,7 @@ def fmt_goal(goal, msg, max_goal_len, argstr):
|
|||
msg_style = args.msg_style.strip() if args.msg_style else "$(MSG_STYLE)"
|
||||
return (
|
||||
ansi.style(f" {goal:>{max_goal_len}}", goal_style)
|
||||
+ f" $(HELP_SEP) "
|
||||
+ " $(HELP_SEP) "
|
||||
+ ansi.style(msg, msg_style)
|
||||
)
|
||||
def fmt_rawmsg(msg, argstr, maxlens):
|
||||
|
@ -237,10 +237,13 @@ print(f"""$(2)""")
|
|||
endef
|
||||
define print_ansi_py
|
||||
$(ansi_py)
|
||||
sep = f"$(HELP_SEP)"
|
||||
codes_names = {getattr(ansi, attr): attr for attr in ansi.__dict__}
|
||||
for code in sorted(codes_names.keys(), key=lambda item: (len(item), item)):
|
||||
print(f"{codes_names[code]:>20} {sep} {code+'*****'+ansi.end} {sep} {repr(code)}")
|
||||
print(
|
||||
"{:>20} $(HELP_SEP) {} $(HELP_SEP) {}".format(
|
||||
codes_names[code], code + "******" + ansi.end, repr(code)
|
||||
)
|
||||
)
|
||||
endef
|
||||
define vars_py
|
||||
import os
|
||||
|
|
Loading…
Reference in a new issue