Compare commits

..

7 commits

9 changed files with 24 additions and 45 deletions

View file

@ -32,7 +32,8 @@ 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
@git add task.mk 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 commit -m "release: v$(VERSION)" --no-verify
@git tag v$(VERSION)
@ -53,7 +54,6 @@ version-check:
$(call tprint-sh,{a.green}VERSION LOOKS GOOD!{a.end});\
fi
## info | demonstrate usage of tprint
.PHONY: task
info:
@ -62,23 +62,18 @@ 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}
make <recipe>
{a.$(HEADER_STYLE)}usage:{a.end}\n make <recipe>\n
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.
See the example output below.\n
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})

View file

@ -4,7 +4,12 @@
<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.
@ -32,14 +37,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.14/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.19/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.14/task.mk -o .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)
```
For more info see the [documentation](https://gh.dayl.in/task.mk).
@ -52,6 +57,7 @@ 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)\

View file

@ -1,7 +1,3 @@
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:

View file

@ -1,6 +1,3 @@
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
@ -34,14 +31,6 @@ 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>

View file

@ -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/blob/main/task.mk).
I agree, all you need is one file [`.task.mk`](https://github.com/daylinmorgan/task.mk/v22.9.19/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.14/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.19/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.14/task.mk -o .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)
```
Alternatively, you can use the builtin rule `_update-task.mk` to update to the latest development version.

View file

@ -9,4 +9,4 @@ DIVIDER ?= ─
HELP_SEP ?=
# python f-string literals
EPILOG ?=
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n

View file

@ -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)
+ " $(HELP_SEP) "
+ f" $(HELP_SEP) "
+ ansi.style(msg, msg_style)
)

View file

@ -2,13 +2,9 @@
#% 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(
"{:>20} $(HELP_SEP) {} $(HELP_SEP) {}".format(
codes_names[code], code + "******" + ansi.end, repr(code)
)
)
print(f"{codes_names[code]:>20} {sep} {code+'*****'+ansi.end} {sep} {repr(code)}")
#% endblock %#

13
task.mk
View file

@ -1,7 +1,7 @@
# }> [github.com/daylinmorgan/task.mk] <{ #
# Copyright (c) 2022 Daylin Morgan
# MIT License
# version: v22.9.14-18-g1a018e2-dev
# version: 22.9.19
#
# 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>
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n
# ---- [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)
+ " $(HELP_SEP) "
+ f" $(HELP_SEP) "
+ ansi.style(msg, msg_style)
)
def fmt_rawmsg(msg, argstr, maxlens):
@ -237,13 +237,10 @@ 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(
"{:>20} $(HELP_SEP) {} $(HELP_SEP) {}".format(
codes_names[code], code + "******" + ansi.end, repr(code)
)
)
print(f"{codes_names[code]:>20} {sep} {code+'*****'+ansi.end} {sep} {repr(code)}")
endef
define vars_py
import os