Compare commits

...

9 commits

13 changed files with 134 additions and 101 deletions

View file

@ -1,4 +1,4 @@
VERSION ?= $(shell git describe --tags --always --dirty=dev)
VERSION ?= $(shell git describe --tags --always --dirty=-dev)
TEMPLATES := $(shell find src/ -type f)
.DEFAULT_GOAL := help
msg = $(if $(tprint),$(call tprint,{a.bold}==> {a.magenta}$(1){a.end}),@echo '==> $(1)')
@ -29,6 +29,7 @@ assets: ## generate assets
define release_sh
./generate.py $(subst v,,$(VERSION)) > task.mk
sed -i 's/task.mk\/.*\/task.mk/task.mk\/$(VERSION)\/task.mk/g' README.md docs/index.md
sed -i 's/TASKMK_VERSION=.*/TASKMK_VERSION=$(VERSION)/' docs/init
git add task.mk README.md docs/index.md
git commit -m "release: $(VERSION)" --no-verify
git tag $(VERSION)
@ -44,11 +45,13 @@ c clean: ## remove the generated files
@rm -f task.mk .task.mk
define version_check_sh
if [[ "${VERSION}" == *'-'* ]]; then
$(call tprint-sh,{a.red}VERSION INVALID! Uncommited or untagged work{a.end})
if git rev-parse -q --verify "refs/tags/${VERSION}" >/dev/null; then
$(call tprint-verbose,{a.red}VERSION INVALID!{a.end} tag already exists); exit 1;
elif [[ "${VERSION}" == *'-'* ]]; then
$(call tprint-verbose,{a.red}VERSION INVALID!{a.end} Uncommited or untagged work); exit 1;
exit 1
elif [[ $(shell echo "${VERSION}" | awk -F. '{ print NF }') -lt 3 ]];then\
$(call tprint-sh,{a.red}VERSION INVALID! Expected CalVer string{a.end})
$(call tprint-verbose,{a.red}VERSION INVALID!{a.end} Expected CalVer string)
exit 1
fi
endef
@ -69,7 +72,7 @@ info: ## demonstrate usage of tprint
task.mk: $(TEMPLATES) generate.py
./generate.py $(VERSION) > task.mk
-include .task.mk .task.cfg.mk
-include .task.cfg.mk .task.mk
.task.mk: $(TEMPLATES) generate.py
$(call msg,re-jinjaing the local .task.mk)
@./generate.py $(VERSION) > .task.mk || (echo "generator failed!!" && rm .task.mk)

View file

@ -32,19 +32,24 @@ You can automagically include it with just two additional lines to your `Makefil
## Setup
One line setup:
```bash
bash <(curl -fsSL gh.dayl.in/task.mk/init) # or w/ TASKMK_VERSION=
```
You can include this as an optional dependency on your project by adding the below lines to the end of your `Makefile`.
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.28/task.mk -o .task.mk))
$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v23.1.1/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.28/task.mk -o .task.mk)
$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v23.1.1/task.mk -o .task.mk)
```
For more info see the [documentation](https://gh.dayl.in/task.mk).

View file

@ -16,14 +16,14 @@
font-weight: 700;
}
.terminal-3882219697-matrix {
.terminal-3478059149-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
.terminal-3882219697-title {
.terminal-3478059149-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
@ -33,100 +33,100 @@
-webkit-filter: drop-shadow( 2px 5px 2px rgba(0, 0, 0, .7));
filter: drop-shadow( 2px 5px 2px rgba(0, 0, 0, .7));
}
.terminal-3882219697-r1 { fill: #94e2d5;font-weight: bold }
.terminal-3882219697-r2 { fill: #c6d0f5 }
.terminal-3882219697-r3 { fill: #f5c2e7;font-weight: bold }
.terminal-3882219697-r4 { fill: #c6d0f5;font-style: italic;;text-decoration: underline; }
.terminal-3882219697-r5 { fill: #a6e3a1;font-weight: bold }
.terminal-3882219697-r6 { fill: #f9e2af;font-weight: bold }
.terminal-3882219697-r7 { fill: #8288a5 }
.terminal-3478059149-r1 { fill: #94e2d5;font-weight: bold }
.terminal-3478059149-r2 { fill: #c6d0f5 }
.terminal-3478059149-r3 { fill: #f5c2e7;font-weight: bold }
.terminal-3478059149-r4 { fill: #c6d0f5;font-style: italic;;text-decoration: underline; }
.terminal-3478059149-r5 { fill: #a6e3a1;font-weight: bold }
.terminal-3478059149-r6 { fill: #f9e2af;font-weight: bold }
.terminal-3478059149-r7 { fill: #8288a5 }
</style>
<defs>
<clipPath id="terminal-3882219697-clip-terminal">
<clipPath id="terminal-3478059149-clip-terminal">
<rect x="0" y="0" width="535.8" height="438.2" />
</clipPath>
<clipPath id="terminal-3882219697-line-0">
<clipPath id="terminal-3478059149-line-0">
<rect x="0" y="1.5" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-1">
<clipPath id="terminal-3478059149-line-1">
<rect x="0" y="25.9" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-2">
<clipPath id="terminal-3478059149-line-2">
<rect x="0" y="50.3" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-3">
<clipPath id="terminal-3478059149-line-3">
<rect x="0" y="74.7" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-4">
<clipPath id="terminal-3478059149-line-4">
<rect x="0" y="99.1" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-5">
<clipPath id="terminal-3478059149-line-5">
<rect x="0" y="123.5" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-6">
<clipPath id="terminal-3478059149-line-6">
<rect x="0" y="147.9" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-7">
<clipPath id="terminal-3478059149-line-7">
<rect x="0" y="172.3" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-8">
<clipPath id="terminal-3478059149-line-8">
<rect x="0" y="196.7" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-9">
<clipPath id="terminal-3478059149-line-9">
<rect x="0" y="221.1" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-10">
<clipPath id="terminal-3478059149-line-10">
<rect x="0" y="245.5" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-11">
<clipPath id="terminal-3478059149-line-11">
<rect x="0" y="269.9" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-12">
<clipPath id="terminal-3478059149-line-12">
<rect x="0" y="294.3" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-13">
<clipPath id="terminal-3478059149-line-13">
<rect x="0" y="318.7" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-14">
<clipPath id="terminal-3478059149-line-14">
<rect x="0" y="343.1" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-15">
<clipPath id="terminal-3478059149-line-15">
<rect x="0" y="367.5" width="536.8" height="24.65"/>
</clipPath>
<clipPath id="terminal-3882219697-line-16">
<clipPath id="terminal-3478059149-line-16">
<rect x="0" y="391.9" width="536.8" height="24.65"/>
</clipPath>
</defs>
<rect fill="#1e1e2e" stroke="rgba(255,255,255,0.35)" stroke-width="1" x="10.1667" y="1" width="553" height="487.2" rx="8"/><text class="terminal-3882219697-title" fill="#c6d0f5" text-anchor="middle" x="276" y="27">make&#160;help</text>
<rect fill="#1e1e2e" stroke="rgba(255,255,255,0.35)" stroke-width="1" x="10.1667" y="1" width="553" height="487.2" rx="8"/><text class="terminal-3478059149-title" fill="#c6d0f5" text-anchor="middle" x="276" y="27">make&#160;help</text>
<g transform="translate(32,22)">
<circle cx="0" cy="0" r="7" fill="#ff5f57"/>
<circle cx="22" cy="0" r="7" fill="#febc2e"/>
<circle cx="44" cy="0" r="7" fill="#28c840"/>
</g>
<g transform="translate(18.166666666666664, 41) scale(.95)" clip-path="url(#terminal-3882219697-clip-terminal)">
<g transform="translate(18.166666666666664, 41) scale(.95)" clip-path="url(#terminal-3478059149-clip-terminal)">
<g class="terminal-3882219697-matrix">
<text class="terminal-3882219697-r1" x="0" y="20" textLength="73.2" clip-path="url(#terminal-3882219697-line-0)">usage:</text><text class="terminal-3882219697-r2" x="536.8" y="20" textLength="12.2" clip-path="url(#terminal-3882219697-line-0)">
</text><text class="terminal-3882219697-r2" x="97.6" y="44.4" textLength="158.6" clip-path="url(#terminal-3882219697-line-1)">make&#160;&lt;recipe&gt;</text><text class="terminal-3882219697-r2" x="536.8" y="44.4" textLength="12.2" clip-path="url(#terminal-3882219697-line-1)">
</text><text class="terminal-3882219697-r2" x="536.8" y="68.8" textLength="12.2" clip-path="url(#terminal-3882219697-line-2)">
</text><text class="terminal-3882219697-r2" x="0" y="93.2" textLength="146.4" clip-path="url(#terminal-3882219697-line-3)">&#160;&#160;Turn&#160;your&#160;</text><text class="terminal-3882219697-r3" x="146.4" y="93.2" textLength="122" clip-path="url(#terminal-3882219697-line-3)">`Makefile`</text><text class="terminal-3882219697-r2" x="268.4" y="93.2" textLength="61" clip-path="url(#terminal-3882219697-line-3)">&#160;into</text><text class="terminal-3882219697-r2" x="536.8" y="93.2" textLength="12.2" clip-path="url(#terminal-3882219697-line-3)">
</text><text class="terminal-3882219697-r2" x="0" y="117.6" textLength="73.2" clip-path="url(#terminal-3882219697-line-4)">&#160;&#160;the&#160;</text><text class="terminal-3882219697-r4" x="73.2" y="117.6" textLength="134.2" clip-path="url(#terminal-3882219697-line-4)">task&#160;runner</text><text class="terminal-3882219697-r2" x="207.4" y="117.6" textLength="231.8" clip-path="url(#terminal-3882219697-line-4)">&#160;you&#160;always&#160;needed.</text><text class="terminal-3882219697-r2" x="536.8" y="117.6" textLength="12.2" clip-path="url(#terminal-3882219697-line-4)">
</text><text class="terminal-3882219697-r2" x="0" y="142" textLength="378.2" clip-path="url(#terminal-3882219697-line-5)">&#160;&#160;See&#160;the&#160;example&#160;output&#160;below.</text><text class="terminal-3882219697-r2" x="536.8" y="142" textLength="12.2" clip-path="url(#terminal-3882219697-line-5)">
</text><text class="terminal-3882219697-r2" x="536.8" y="166.4" textLength="12.2" clip-path="url(#terminal-3882219697-line-6)">
</text><text class="terminal-3882219697-r5" x="24.4" y="190.8" textLength="475.8" clip-path="url(#terminal-3882219697-line-7)">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;task.mk&#160;development&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</text><text class="terminal-3882219697-r2" x="536.8" y="190.8" textLength="12.2" clip-path="url(#terminal-3882219697-line-7)">
</text><text class="terminal-3882219697-r2" x="0" y="215.2" textLength="536.8" clip-path="url(#terminal-3882219697-line-8)">&#160;&#160;──────────────────────────────────────────</text><text class="terminal-3882219697-r2" x="536.8" y="215.2" textLength="12.2" clip-path="url(#terminal-3882219697-line-8)">
</text><text class="terminal-3882219697-r6" x="0" y="239.6" textLength="134.2" clip-path="url(#terminal-3882219697-line-9)">&#160;&#160;bootstrap</text><text class="terminal-3882219697-r2" x="134.2" y="239.6" textLength="36.6" clip-path="url(#terminal-3882219697-line-9)">&#160;&#160;</text><text class="terminal-3882219697-r7" x="170.8" y="239.6" textLength="366" clip-path="url(#terminal-3882219697-line-9)">generate&#160;local&#160;dev&#160;environment</text><text class="terminal-3882219697-r2" x="536.8" y="239.6" textLength="12.2" clip-path="url(#terminal-3882219697-line-9)">
</text><text class="terminal-3882219697-r6" x="0" y="264" textLength="134.2" clip-path="url(#terminal-3882219697-line-10)">&#160;&#160;&#160;&#160;l,&#160;lint</text><text class="terminal-3882219697-r2" x="134.2" y="264" textLength="36.6" clip-path="url(#terminal-3882219697-line-10)">&#160;&#160;</text><text class="terminal-3882219697-r7" x="170.8" y="264" textLength="183" clip-path="url(#terminal-3882219697-line-10)">lint&#160;the&#160;python</text><text class="terminal-3882219697-r2" x="536.8" y="264" textLength="12.2" clip-path="url(#terminal-3882219697-line-10)">
</text><text class="terminal-3882219697-r6" x="0" y="288.4" textLength="134.2" clip-path="url(#terminal-3882219697-line-11)">&#160;&#160;&#160;&#160;&#160;assets</text><text class="terminal-3882219697-r2" x="134.2" y="288.4" textLength="36.6" clip-path="url(#terminal-3882219697-line-11)">&#160;&#160;</text><text class="terminal-3882219697-r7" x="170.8" y="288.4" textLength="183" clip-path="url(#terminal-3882219697-line-11)">generate&#160;assets</text><text class="terminal-3882219697-r2" x="536.8" y="288.4" textLength="12.2" clip-path="url(#terminal-3882219697-line-11)">
</text><text class="terminal-3882219697-r6" x="0" y="312.8" textLength="134.2" clip-path="url(#terminal-3882219697-line-12)">&#160;&#160;&#160;&#160;release</text><text class="terminal-3882219697-r2" x="134.2" y="312.8" textLength="36.6" clip-path="url(#terminal-3882219697-line-12)">&#160;&#160;</text><text class="terminal-3882219697-r7" x="170.8" y="312.8" textLength="366" clip-path="url(#terminal-3882219697-line-12)">release&#160;new&#160;version&#160;of&#160;task.mk</text><text class="terminal-3882219697-r2" x="536.8" y="312.8" textLength="12.2" clip-path="url(#terminal-3882219697-line-12)">
</text><text class="terminal-3882219697-r6" x="0" y="337.2" textLength="134.2" clip-path="url(#terminal-3882219697-line-13)">&#160;&#160;&#160;c,&#160;clean</text><text class="terminal-3882219697-r2" x="134.2" y="337.2" textLength="36.6" clip-path="url(#terminal-3882219697-line-13)">&#160;&#160;</text><text class="terminal-3882219697-r7" x="170.8" y="337.2" textLength="317.2" clip-path="url(#terminal-3882219697-line-13)">remove&#160;the&#160;generated&#160;files</text><text class="terminal-3882219697-r2" x="536.8" y="337.2" textLength="12.2" clip-path="url(#terminal-3882219697-line-13)">
</text><text class="terminal-3882219697-r6" x="0" y="361.6" textLength="134.2" clip-path="url(#terminal-3882219697-line-14)">&#160;&#160;&#160;&#160;&#160;&#160;&#160;info</text><text class="terminal-3882219697-r2" x="134.2" y="361.6" textLength="36.6" clip-path="url(#terminal-3882219697-line-14)">&#160;&#160;</text><text class="terminal-3882219697-r7" x="170.8" y="361.6" textLength="329.4" clip-path="url(#terminal-3882219697-line-14)">demonstrate&#160;usage&#160;of&#160;tprint</text><text class="terminal-3882219697-r2" x="536.8" y="361.6" textLength="12.2" clip-path="url(#terminal-3882219697-line-14)">
</text><text class="terminal-3882219697-r6" x="0" y="386" textLength="134.2" clip-path="url(#terminal-3882219697-line-15)">&#160;&#160;&#160;&#160;h,&#160;help</text><text class="terminal-3882219697-r2" x="134.2" y="386" textLength="36.6" clip-path="url(#terminal-3882219697-line-15)">&#160;&#160;</text><text class="terminal-3882219697-r7" x="170.8" y="386" textLength="170.8" clip-path="url(#terminal-3882219697-line-15)">show&#160;this&#160;help</text><text class="terminal-3882219697-r2" x="536.8" y="386" textLength="12.2" clip-path="url(#terminal-3882219697-line-15)">
</text><text class="terminal-3882219697-r2" x="536.8" y="410.4" textLength="12.2" clip-path="url(#terminal-3882219697-line-16)">
</text><text class="terminal-3882219697-r2" x="0" y="434.8" textLength="402.6" clip-path="url(#terminal-3882219697-line-17)">for&#160;more&#160;info:&#160;gh.dayl.in/task.mk</text><text class="terminal-3882219697-r2" x="536.8" y="434.8" textLength="12.2" clip-path="url(#terminal-3882219697-line-17)">
<g class="terminal-3478059149-matrix">
<text class="terminal-3478059149-r1" x="0" y="20" textLength="61" clip-path="url(#terminal-3478059149-line-0)">usage</text><text class="terminal-3478059149-r2" x="61" y="20" textLength="12.2" clip-path="url(#terminal-3478059149-line-0)">:</text><text class="terminal-3478059149-r2" x="536.8" y="20" textLength="12.2" clip-path="url(#terminal-3478059149-line-0)">
</text><text class="terminal-3478059149-r2" x="97.6" y="44.4" textLength="158.6" clip-path="url(#terminal-3478059149-line-1)">make&#160;&lt;recipe&gt;</text><text class="terminal-3478059149-r2" x="536.8" y="44.4" textLength="12.2" clip-path="url(#terminal-3478059149-line-1)">
</text><text class="terminal-3478059149-r2" x="536.8" y="68.8" textLength="12.2" clip-path="url(#terminal-3478059149-line-2)">
</text><text class="terminal-3478059149-r2" x="0" y="93.2" textLength="146.4" clip-path="url(#terminal-3478059149-line-3)">&#160;&#160;Turn&#160;your&#160;</text><text class="terminal-3478059149-r3" x="146.4" y="93.2" textLength="122" clip-path="url(#terminal-3478059149-line-3)">`Makefile`</text><text class="terminal-3478059149-r2" x="268.4" y="93.2" textLength="61" clip-path="url(#terminal-3478059149-line-3)">&#160;into</text><text class="terminal-3478059149-r2" x="536.8" y="93.2" textLength="12.2" clip-path="url(#terminal-3478059149-line-3)">
</text><text class="terminal-3478059149-r2" x="0" y="117.6" textLength="73.2" clip-path="url(#terminal-3478059149-line-4)">&#160;&#160;the&#160;</text><text class="terminal-3478059149-r4" x="73.2" y="117.6" textLength="134.2" clip-path="url(#terminal-3478059149-line-4)">task&#160;runner</text><text class="terminal-3478059149-r2" x="207.4" y="117.6" textLength="231.8" clip-path="url(#terminal-3478059149-line-4)">&#160;you&#160;always&#160;needed.</text><text class="terminal-3478059149-r2" x="536.8" y="117.6" textLength="12.2" clip-path="url(#terminal-3478059149-line-4)">
</text><text class="terminal-3478059149-r2" x="0" y="142" textLength="378.2" clip-path="url(#terminal-3478059149-line-5)">&#160;&#160;See&#160;the&#160;example&#160;output&#160;below.</text><text class="terminal-3478059149-r2" x="536.8" y="142" textLength="12.2" clip-path="url(#terminal-3478059149-line-5)">
</text><text class="terminal-3478059149-r2" x="536.8" y="166.4" textLength="12.2" clip-path="url(#terminal-3478059149-line-6)">
</text><text class="terminal-3478059149-r5" x="24.4" y="190.8" textLength="475.8" clip-path="url(#terminal-3478059149-line-7)">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;task.mk&#160;development&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</text><text class="terminal-3478059149-r2" x="536.8" y="190.8" textLength="12.2" clip-path="url(#terminal-3478059149-line-7)">
</text><text class="terminal-3478059149-r2" x="0" y="215.2" textLength="536.8" clip-path="url(#terminal-3478059149-line-8)">&#160;&#160;──────────────────────────────────────────</text><text class="terminal-3478059149-r2" x="536.8" y="215.2" textLength="12.2" clip-path="url(#terminal-3478059149-line-8)">
</text><text class="terminal-3478059149-r1" x="0" y="239.6" textLength="134.2" clip-path="url(#terminal-3478059149-line-9)">&#160;&#160;bootstrap</text><text class="terminal-3478059149-r2" x="134.2" y="239.6" textLength="36.6" clip-path="url(#terminal-3478059149-line-9)">&#160;&#160;</text><text class="terminal-3478059149-r3" x="170.8" y="239.6" textLength="366" clip-path="url(#terminal-3478059149-line-9)">generate&#160;local&#160;dev&#160;environment</text><text class="terminal-3478059149-r2" x="536.8" y="239.6" textLength="12.2" clip-path="url(#terminal-3478059149-line-9)">
</text><text class="terminal-3478059149-r6" x="0" y="264" textLength="134.2" clip-path="url(#terminal-3478059149-line-10)">&#160;&#160;&#160;&#160;&#160;l&#160;lint</text><text class="terminal-3478059149-r2" x="134.2" y="264" textLength="36.6" clip-path="url(#terminal-3478059149-line-10)">&#160;&#160;</text><text class="terminal-3478059149-r7" x="170.8" y="264" textLength="183" clip-path="url(#terminal-3478059149-line-10)">lint&#160;the&#160;python</text><text class="terminal-3478059149-r2" x="536.8" y="264" textLength="12.2" clip-path="url(#terminal-3478059149-line-10)">
</text><text class="terminal-3478059149-r6" x="0" y="288.4" textLength="134.2" clip-path="url(#terminal-3478059149-line-11)">&#160;&#160;&#160;&#160;&#160;assets</text><text class="terminal-3478059149-r2" x="134.2" y="288.4" textLength="36.6" clip-path="url(#terminal-3478059149-line-11)">&#160;&#160;</text><text class="terminal-3478059149-r7" x="170.8" y="288.4" textLength="183" clip-path="url(#terminal-3478059149-line-11)">generate&#160;assets</text><text class="terminal-3478059149-r2" x="536.8" y="288.4" textLength="12.2" clip-path="url(#terminal-3478059149-line-11)">
</text><text class="terminal-3478059149-r6" x="0" y="312.8" textLength="134.2" clip-path="url(#terminal-3478059149-line-12)">&#160;&#160;&#160;&#160;release</text><text class="terminal-3478059149-r2" x="134.2" y="312.8" textLength="36.6" clip-path="url(#terminal-3478059149-line-12)">&#160;&#160;</text><text class="terminal-3478059149-r7" x="170.8" y="312.8" textLength="366" clip-path="url(#terminal-3478059149-line-12)">release&#160;new&#160;version&#160;of&#160;task.mk</text><text class="terminal-3478059149-r2" x="536.8" y="312.8" textLength="12.2" clip-path="url(#terminal-3478059149-line-12)">
</text><text class="terminal-3478059149-r6" x="0" y="337.2" textLength="134.2" clip-path="url(#terminal-3478059149-line-13)">&#160;&#160;&#160;&#160;c&#160;clean</text><text class="terminal-3478059149-r2" x="134.2" y="337.2" textLength="36.6" clip-path="url(#terminal-3478059149-line-13)">&#160;&#160;</text><text class="terminal-3478059149-r7" x="170.8" y="337.2" textLength="317.2" clip-path="url(#terminal-3478059149-line-13)">remove&#160;the&#160;generated&#160;files</text><text class="terminal-3478059149-r2" x="536.8" y="337.2" textLength="12.2" clip-path="url(#terminal-3478059149-line-13)">
</text><text class="terminal-3478059149-r6" x="0" y="361.6" textLength="134.2" clip-path="url(#terminal-3478059149-line-14)">&#160;&#160;&#160;&#160;&#160;&#160;&#160;info</text><text class="terminal-3478059149-r2" x="134.2" y="361.6" textLength="36.6" clip-path="url(#terminal-3478059149-line-14)">&#160;&#160;</text><text class="terminal-3478059149-r7" x="170.8" y="361.6" textLength="329.4" clip-path="url(#terminal-3478059149-line-14)">demonstrate&#160;usage&#160;of&#160;tprint</text><text class="terminal-3478059149-r2" x="536.8" y="361.6" textLength="12.2" clip-path="url(#terminal-3478059149-line-14)">
</text><text class="terminal-3478059149-r6" x="0" y="386" textLength="134.2" clip-path="url(#terminal-3478059149-line-15)">&#160;&#160;&#160;&#160;&#160;h&#160;help</text><text class="terminal-3478059149-r2" x="134.2" y="386" textLength="36.6" clip-path="url(#terminal-3478059149-line-15)">&#160;&#160;</text><text class="terminal-3478059149-r7" x="170.8" y="386" textLength="170.8" clip-path="url(#terminal-3478059149-line-15)">show&#160;this&#160;help</text><text class="terminal-3478059149-r2" x="536.8" y="386" textLength="12.2" clip-path="url(#terminal-3478059149-line-15)">
</text><text class="terminal-3478059149-r2" x="536.8" y="410.4" textLength="12.2" clip-path="url(#terminal-3478059149-line-16)">
</text><text class="terminal-3478059149-r2" x="0" y="434.8" textLength="402.6" clip-path="url(#terminal-3478059149-line-17)">for&#160;more&#160;info:&#160;gh.dayl.in/task.mk</text><text class="terminal-3478059149-r2" x="536.8" y="434.8" textLength="12.2" clip-path="url(#terminal-3478059149-line-17)">
</text>
</g>
</g>

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -23,7 +23,7 @@ Current Features:
Depends on `GNU Make`, obviously and `Python >=3.7`, and `bash` (or `zsh`).
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.28/task.mk).
I agree, all you need is one file [`.task.mk`](https://github.com/daylinmorgan/task.mk/v23.1.1/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.28/task.mk -o .task.mk))
$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v23.1.1/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.28/task.mk -o .task.mk)
$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v23.1.1/task.mk -o .task.mk)
```
Alternatively, you can use the builtin rule `_update-task.mk` to update to the latest development version.

31
docs/init Normal file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -e
TASKMK_VERSION=v23.1.1
VERSION=${1:-$TASKMK_VERSION}
printf "Initializing Task.mk (%s) for repo\n" "$VERSION"
if [ -f "./.task.mk" ]; then
echo "Found local .task.mk."
echo "Was it already initialized?"
echo 'Exiting....'
exit 0
fi
curl -fsSL "https://raw.githubusercontent.com/daylinmorgan/task.mk/$VERSION/task.mk" -o .task.mk
echo .task.mk >>.gitignore
echo '-include .task.cfg.mk .task.mk' >>Makefile
printf '$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/%s/task.mk -o .task.mk))' \
"$VERSION" \
>>Makefile
printf ".task.mk files added to repo\n\n"
echo "Do you want to commit these changes?"
printf "RUN COMMAND: %s (Y/n) " \
"git add Makefile .gitignore && git commit -m \"chore: initialize .task.mk\""
read -r answer
# if echo "$answer" | grep -iq "^y" ;then
if [ "$answer" != "${answer#[Yy]}" ]; then
git add Makefile .gitignore && git commit -m "chore: initialize .task.mk"
echo finished.
else
echo finished.
fi

View file

@ -8,10 +8,10 @@ h help: ## show this help
_help: export SHOW_HIDDEN=true
_help: help
ifdef PRINT_VARS
$(foreach v,$(PRINT_VARS),$(eval export $(v)))
TASKMK_VARS=$(subst $(eval ) ,<|>,$(foreach v,$(PRINT_VARS),$(v)=$($(v))))
.PHONY: vars v
vars v:
$(call py,vars_py,$(PRINT_VARS))
v vars:
$(call py,vars_py,$(TASKMK_VARS))
endif
### |> -ws --hidden
### task.mk builtins: |> -d --hidden
@ -19,11 +19,11 @@ _print-ansi: ## show all possible ansi color code combinations
$(call py,print_ansi_py)
# functions to take f-string literals and pass to python print
tprint = $(call py,print_py,$(1))
tprint-sh = $(call pysh,print_py,$(1))
tprint-verbose= $(call py-verbose,print_py,$(1))
tconfirm = $(call py,confirm_py,$(1))
_update-task.mk: ## downloads latest development version of task.mk
_update-task.mk: ## downloads version of task.mk (TASKMK_VERSION=)
$(call tprint,{a.b_cyan}Updating task.mk{a.end})
curl https://raw.githubusercontent.com/daylinmorgan/task.mk/main/task.mk -o .task.mk
curl https://raw.githubusercontent.com/daylinmorgan/task.mk/$(TASKMK_VERSION)/task.mk -o .task.mk
.PHONY: h help _help _print-ansi _update-task.mk
TASK_MAKEFILE_LIST := $(filter-out $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)),$(MAKEFILE_LIST))
export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST

View file

@ -1,8 +1,7 @@
# }> [github.com/daylinmorgan/task.mk] <{ #
# Copyright (c) 2022 Daylin Morgan
# MIT License
# version: ##- version -##
#
TASKMK_VERSION ?= ##- version -##
# 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.
# You can update your .task.mk with `make _update-task.mk`

View file

@ -23,17 +23,17 @@ MaxLens = namedtuple("MaxLens", "goal msg")
pattern = re.compile(
r"""
(?:
^\#\#\#\s+
^\#\#\#\s+ # <- raw message
|
^(?:
(?:\#\#\s+)?
(?P<goal>.*?)(?:\s+\|>|:.*?\#\#)\s+
) # <- a custom goal or actual recipe
)
)
(?P<msg>.*?)?\s?
(?P<msg>.*?)?\s? # <- help text (optional)
(?:\|>\s+
(?P<msgargs>.*?)
)?
)? # <- style args (optional)
$$
""",
re.X,

View file

@ -3,5 +3,6 @@
#% block script %#
##- '$(utils_py)' -##
###- sys is imported with utils_py -###
###- $(2) f-string from task.mk -###
sys.stderr.write(f"""$(2)\n""")
#% endblock %#

View file

@ -21,4 +21,4 @@ else
py = @python3 <(printf "$(call _create_string,$($(1)))")
tbash = @bash <(printf "$(call _create_string,$($(1)))")
endif
pysh = python3 <(printf "$(call _create_string,$($(1)))")
py-verbose = python3 <(printf "$(call _create_string,$($(1)))")

View file

@ -96,7 +96,7 @@ class Ansi:
sys.exit(1)
return code + end
###- the below $() variables are injected by make -###
def add_cfg(self):
cfg_styles = {
"header": "$(HEADER_STYLE)",
@ -118,6 +118,7 @@ class Ansi:
a = ansi = Ansi()
###- the below $() variables are injected by make -###
cfg = Config(
"$(DIVIDER)", "$(HELP_SEP)", f"""$(EPILOG)""", f"""$(USAGE)""", int("$(WRAP)")
)

View file

@ -10,15 +10,10 @@ from utils import Ansi
# -###
##- '$(utils_py)' -##
ansi = Ansi(target="stdout")
vars = "$2".split()
length = max((len(v) for v in vars))
print(f"{ansi.header}vars{ansi.end}:\n")
for v in vars:
print(f" {ansi.params}{v:<{length}}{ansi.end} = {os.getenv(v)}")
print()
###- $2 is a list of variables set by task.mk delimited with '<|>' -###
task_vars = tuple(v.split('=') for v in "$2".split('<|>'))
length = max((len(v[0]) for v in task_vars))
rows = (f" {ansi.params}{v[0]:<{length}}{ansi.end} = {v[1]}" for v in task_vars)
print('\n'.join((f"{ansi.header}vars{ansi.end}:\n", *rows,'')))
#% endblock %#

36
task.mk
View file

@ -1,8 +1,7 @@
# }> [github.com/daylinmorgan/task.mk] <{ #
# Copyright (c) 2022 Daylin Morgan
# MIT License
# version: v22.9.28-13-gfd96a45dev
#
TASKMK_VERSION ?= 23.1.1
# 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.
# You can update your .task.mk with `make _update-task.mk`
@ -30,10 +29,10 @@ h help: ## show this help
_help: export SHOW_HIDDEN=true
_help: help
ifdef PRINT_VARS
$(foreach v,$(PRINT_VARS),$(eval export $(v)))
TASKMK_VARS=$(subst $(eval ) ,<|>,$(foreach v,$(PRINT_VARS),$(v)=$($(v))))
.PHONY: vars v
vars v:
$(call py,vars_py,$(PRINT_VARS))
v vars:
$(call py,vars_py,$(TASKMK_VARS))
endif
### |> -ws --hidden
### task.mk builtins: |> -d --hidden
@ -41,11 +40,11 @@ _print-ansi: ## show all possible ansi color code combinations
$(call py,print_ansi_py)
# functions to take f-string literals and pass to python print
tprint = $(call py,print_py,$(1))
tprint-sh = $(call pysh,print_py,$(1))
tprint-verbose= $(call py-verbose,print_py,$(1))
tconfirm = $(call py,confirm_py,$(1))
_update-task.mk: ## downloads latest development version of task.mk
_update-task.mk: ## downloads version of task.mk (TASKMK_VERSION=)
$(call tprint,{a.b_cyan}Updating task.mk{a.end})
curl https://raw.githubusercontent.com/daylinmorgan/task.mk/main/task.mk -o .task.mk
curl https://raw.githubusercontent.com/daylinmorgan/task.mk/$(TASKMK_VERSION)/task.mk -o .task.mk
.PHONY: h help _help _print-ansi _update-task.mk
TASK_MAKEFILE_LIST := $(filter-out $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)),$(MAKEFILE_LIST))
export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST
@ -74,7 +73,7 @@ else
py = @python3 <(printf "$(call _create_string,$($(1)))")
tbash = @bash <(printf "$(call _create_string,$($(1)))")
endif
pysh = python3 <(printf "$(call _create_string,$($(1)))")
py-verbose = python3 <(printf "$(call _create_string,$($(1)))")
# ---- [python scripts] ---- #
define help_py
import argparse
@ -90,17 +89,17 @@ MaxLens = namedtuple("MaxLens", "goal msg")
pattern = re.compile(
r"""
(?:
^\#\#\#\s+
^\#\#\#\s+ # <- raw message
|
^(?:
(?:\#\#\s+)?
(?P<goal>.*?)(?:\s+\|>|:.*?\#\#)\s+
) # <- a custom goal or actual recipe
)
)
(?P<msg>.*?)?\s?
(?P<msg>.*?)?\s? # <- help text (optional)
(?:\|>\s+
(?P<msgargs>.*?)
)?
)? # <- style args (optional)
$$
""",
re.X,
@ -286,12 +285,10 @@ define vars_py
import os
$(utils_py)
ansi = Ansi(target="stdout")
vars = "$2".split()
length = max((len(v) for v in vars))
print(f"{ansi.header}vars{ansi.end}:\n")
for v in vars:
print(f" {ansi.params}{v:<{length}}{ansi.end} = {os.getenv(v)}")
print()
task_vars = tuple(v.split('=') for v in "$2".split('<|>'))
length = max((len(v[0]) for v in task_vars))
rows = (f" {ansi.params}{v[0]:<{length}}{ansi.end} = {v[1]}" for v in task_vars)
print('\n'.join((f"{ansi.header}vars{ansi.end}:\n", *rows,'')))
endef
define confirm_py
import sys
@ -393,6 +390,7 @@ class Ansi:
print("Expected one or three values for bg as a list")
sys.exit(1)
return code + end
def add_cfg(self):
cfg_styles = {
"header": "$(HEADER_STYLE)",