Compare commits

..

No commits in common. "77e76edd162830abb3252f257ff30d1109ae2a9a" and "8f875a13d1ee65497811df55bf2b21fc022e24b9" have entirely different histories.

9 changed files with 45 additions and 24 deletions

View file

@ -32,8 +32,7 @@ release: version-check
$(call msg,Release Project) $(call msg,Release Project)
@./generate.py $(VERSION) > task.mk @./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' 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
@git add task.mk README.md docs/index.md
@git commit -m "release: v$(VERSION)" --no-verify @git commit -m "release: v$(VERSION)" --no-verify
@git tag v$(VERSION) @git tag v$(VERSION)
@ -54,6 +53,7 @@ version-check:
$(call tprint-sh,{a.green}VERSION LOOKS GOOD!{a.end});\ $(call tprint-sh,{a.green}VERSION LOOKS GOOD!{a.end});\
fi fi
## info | demonstrate usage of tprint ## info | demonstrate usage of tprint
.PHONY: task .PHONY: task
info: info:
@ -62,18 +62,23 @@ info:
$(call tprint,$(mlmsg)) $(call tprint,$(mlmsg))
$(call tprint,{a.custom(fg=(148, 255, 15),bg=(103, 2, 15))}Custom Colors TOO!{a.end}) $(call tprint,{a.custom(fg=(148, 255, 15),bg=(103, 2, 15))}Custom Colors TOO!{a.end})
task.mk: $(TEMPLATES) generate.py task.mk: $(TEMPLATES) generate.py
./generate.py $(VERSION) > task.mk ./generate.py $(VERSION) > task.mk
define USAGE 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 Turn your {a.style('`Makefile`','b_magenta')} into
the {a.italic}{a.underline}task runner{a.end} you always needed. the {a.italic}{a.underline}task runner{a.end} you always needed.
See the example output below.\n See the example output below.
endef endef
EPILOG = \nfor more info: gh.dayl.in/task.mk EPILOG = \nfor more info: gh.dayl.in/task.mk
PRINT_VARS := VERSION PRINT_VARS := VERSION
-include .task.mk -include .task.mk
.task.mk: $(TEMPLATES) generate.py .task.mk: $(TEMPLATES) generate.py
$(call tprint,{a.b_yellow}re-jinjaing the local .task.mk{a.end}) $(call tprint,{a.b_yellow}re-jinjaing the local .task.mk{a.end})

View file

@ -4,12 +4,7 @@
<p align="center"> <p align="center">
the task runner for GNU Make you've been missing the task runner for GNU Make you've been missing
</p> </p>
<p align="center">
<a href="https://gh.dayl.in/task.mk">Documentation</a>
</p>
</div> </div>
</br> </br>
GNU make is an excellent build tool and the task runner we love to hate, but can't escape. 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 ```make
-include .task.mk -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. 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 ```make
-include .task.mk -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). 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 ```make
## h, help | show this help ## h, help | show this help
### additional text printed with the help
.PHONY: help h .PHONY: help h
help h: Makefile help h: Makefile
@awk -v fill=$(shell sed -n 's/^## \(.*\) | .*/\1/p' $< | wc -L)\ @awk -v fill=$(shell sed -n 's/^## \(.*\) | .*/\1/p' $< | wc -L)\

View file

@ -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 ## check | get user confirmation or exit
.PHONY: check .PHONY: check
check: check:

View file

@ -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 ### examples of task.mk features | args: --divider --align center --msg-style b_red
define list_files_py define list_files_py
from pathlib import Path from pathlib import Path
@ -31,6 +34,14 @@ endef
embedded-bash: embedded-bash:
$(call tbash,bash_script,bash multiline is probably working) $(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 define USAGE
{a.$(HEADER_STYLE)}usage:{a.end} {a.$(HEADER_STYLE)}usage:{a.end}
make <recipe> make <recipe>

View file

@ -23,7 +23,7 @@ Current Features:
Depends on `GNU Make`, obviously and `Python >=3.7`. Depends on `GNU Make`, obviously and `Python >=3.7`.
Wait python?!?!, I'm not `pip` installing some package just to parse my makefile. 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. 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 ## Setup
@ -33,14 +33,14 @@ If someone tries to invoke `make help` it will download `.task.mk` for them.
```make ```make
-include .task.mk -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. 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 ```make
-include .task.mk -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. 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 ?= HELP_SEP ?=
# python f-string literals # python f-string literals
EPILOG ?= EPILOG ?=
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>

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)" msg_style = args.msg_style.strip() if args.msg_style else "$(MSG_STYLE)"
return ( return (
ansi.style(f" {goal:>{max_goal_len}}", goal_style) ansi.style(f" {goal:>{max_goal_len}}", goal_style)
+ f" $(HELP_SEP) " + " $(HELP_SEP) "
+ ansi.style(msg, msg_style) + ansi.style(msg, msg_style)
) )

View file

@ -2,9 +2,13 @@
#% block name %#print_ansi#% endblock %# #% block name %#print_ansi#% endblock %#
#% block script %# #% block script %#
##- '$(ansi_py)' -## ##- '$(ansi_py)' -##
sep = f"$(HELP_SEP)"
codes_names = {getattr(ansi, attr): attr for attr in ansi.__dict__} codes_names = {getattr(ansi, attr): attr for attr in ansi.__dict__}
for code in sorted(codes_names.keys(), key=lambda item: (len(item), item)): 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 %# #% endblock %#

13
task.mk
View file

@ -1,7 +1,7 @@
# }> [github.com/daylinmorgan/task.mk] <{ # # }> [github.com/daylinmorgan/task.mk] <{ #
# Copyright (c) 2022 Daylin Morgan # Copyright (c) 2022 Daylin Morgan
# MIT License # 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` # 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. # See below for the standard configuration options that should be set prior to including this file.
@ -17,7 +17,7 @@ DIVIDER ?= ─
HELP_SEP ?= HELP_SEP ?=
# python f-string literals # python f-string literals
EPILOG ?= EPILOG ?=
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>
# ---- [buitlin recipes] ---- # # ---- [buitlin recipes] ---- #
## h, help | show this help ## h, help | show this help
.PHONY: help h .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)" msg_style = args.msg_style.strip() if args.msg_style else "$(MSG_STYLE)"
return ( return (
ansi.style(f" {goal:>{max_goal_len}}", goal_style) ansi.style(f" {goal:>{max_goal_len}}", goal_style)
+ f" $(HELP_SEP) " + " $(HELP_SEP) "
+ ansi.style(msg, msg_style) + ansi.style(msg, msg_style)
) )
def fmt_rawmsg(msg, argstr, maxlens): def fmt_rawmsg(msg, argstr, maxlens):
@ -237,10 +237,13 @@ print(f"""$(2)""")
endef endef
define print_ansi_py define print_ansi_py
$(ansi_py) $(ansi_py)
sep = f"$(HELP_SEP)"
codes_names = {getattr(ansi, attr): attr for attr in ansi.__dict__} codes_names = {getattr(ansi, attr): attr for attr in ansi.__dict__}
for code in sorted(codes_names.keys(), key=lambda item: (len(item), item)): 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 endef
define vars_py define vars_py
import os import os