Compare commits

...

8 commits

11 changed files with 166 additions and 91 deletions

View file

@ -57,7 +57,7 @@ list-%:
.PHONY: version-check
version-check:
@if [[ "${VERSION}" == *'-'* ]]; then\
$(call tprint-sh,{a.red}VERSION INVALID! Uncommited Work{a.end});\
$(call tprint-sh,{a.red}VERSION INVALID! Uncommited or untagged work{a.end});\
echo ">> version: $(VERSION)"; 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});\
@ -68,13 +68,14 @@ version-check:
define bash_script
figlet task.mk 2>/dev/null || echo 'no figlet :('
echo "This is from bash"
cat /etc/hostname
printf "%s\n" "$(2)"
endef
.PHONY: test-bash
test-bash:
$(call tbash,bash_script,test bash multiline)
$(call tbash,bash_script,bash multiline is probably working)
define mlmsg
{a.b_yellow}
@ -92,6 +93,12 @@ info:
$(call tprint,$(mlmsg))
$(call tprint,{a.custom(fg=(148, 255, 15),bg=(103, 2, 15))}Custom Colors TOO!{a.end})
## check | get user confirmation or exit
.PHONY: check
check:
$(call tconfirm,Would you like to proceed?)
@echo "you said yes!"
### | args: --divider
task.mk: $(TEMPLATES) generate.py
@ -112,4 +119,5 @@ PRINT_VARS := VERSION
-include .task.mk
.task.mk: $(TEMPLATES) generate.py
$(call tprint,{a.b_yellow}re-jinjaing the local .task.mk{a.end})
@./generate.py $(VERSION) > .task.mk || (echo "generator failed!!" && rm .task.mk)

View file

@ -17,6 +17,7 @@ Current Features:
- ANSI escape code support (including NO_COLOR)
- formatted help output
- custom print function
- confirmation prompt
Depends on `GNU Make`, obviously and `Python >=3.7`.
@ -105,8 +106,9 @@ PARAMS_COLOR ?= b_magenta
ACCENT_COLOR ?= b_yellow
GOAL_COLOR ?= $(ACCENT_COLOR)
MSG_COLOR ?= faint
HELP_SEP ?= |
HELP_SORT ?= # sort goals alphabetically
DIVIDER_COLOR ?= default
DIVIDER ?= ─
HELP_SEP ?= │
# python f-string literals
EPILOG ?=
@ -151,6 +153,7 @@ For what it's worth there is also a predefined function for `bash` (named `tbash
```make
define bash_script
figlet task.mk 2>/dev/null || echo 'no figlet :('
echo "This is from bash"
cat /etc/hostname
printf "%s\n" "$(2)"
@ -161,7 +164,6 @@ test-bash:
```
## Zsh Completions for GNU Make
If you use `GNU Make` with zsh you may want to add the following

View file

@ -1,4 +1,4 @@
<svg class="rich-terminal shadow" viewBox="0 0 720.3333333333334 692.3333333333334" xmlns="http://www.w3.org/2000/svg">
<svg class="rich-terminal shadow" viewBox="0 0 720.3333333333334 716.7333333333333" xmlns="http://www.w3.org/2000/svg">
<!-- Generated with Rich https://www.textualize.io -->
<style>
@font-face {
@ -16,14 +16,14 @@
font-weight: 700;
}
.terminal-1030366103-matrix {
.terminal-1053897658-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
.terminal-1030366103-title {
.terminal-1053897658-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
@ -33,129 +33,133 @@
-webkit-filter: drop-shadow( 2px 5px 2px rgba(0, 0, 0, .7));
filter: drop-shadow( 2px 5px 2px rgba(0, 0, 0, .7));
}
.terminal-1030366103-r1 { fill: #94e2d5;font-weight: bold }
.terminal-1030366103-r2 { fill: #c6d0f5 }
.terminal-1030366103-r3 { fill: #f5c2e7;font-weight: bold }
.terminal-1030366103-r4 { fill: #c6d0f5;font-style: italic;;text-decoration: underline; }
.terminal-1030366103-r5 { fill: #a6e3a1;font-weight: bold }
.terminal-1030366103-r6 { fill: #f9e2af;font-weight: bold }
.terminal-1030366103-r7 { fill: #8288a5 }
.terminal-1030366103-r8 { fill: #f38ba8;font-weight: bold }
.terminal-1053897658-r1 { fill: #94e2d5;font-weight: bold }
.terminal-1053897658-r2 { fill: #c6d0f5 }
.terminal-1053897658-r3 { fill: #f5c2e7;font-weight: bold }
.terminal-1053897658-r4 { fill: #c6d0f5;font-style: italic;;text-decoration: underline; }
.terminal-1053897658-r5 { fill: #a6e3a1;font-weight: bold }
.terminal-1053897658-r6 { fill: #f9e2af;font-weight: bold }
.terminal-1053897658-r7 { fill: #8288a5 }
.terminal-1053897658-r8 { fill: #f38ba8;font-weight: bold }
</style>
<defs>
<clipPath id="terminal-1030366103-clip-terminal">
<rect x="0" y="0" width="682.1999999999999" height="609.0" />
<clipPath id="terminal-1053897658-clip-terminal">
<rect x="0" y="0" width="682.1999999999999" height="633.4" />
</clipPath>
<clipPath id="terminal-1030366103-line-0">
<clipPath id="terminal-1053897658-line-0">
<rect x="0" y="1.5" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-1">
<clipPath id="terminal-1053897658-line-1">
<rect x="0" y="25.9" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-2">
<clipPath id="terminal-1053897658-line-2">
<rect x="0" y="50.3" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-3">
<clipPath id="terminal-1053897658-line-3">
<rect x="0" y="74.7" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-4">
<clipPath id="terminal-1053897658-line-4">
<rect x="0" y="99.1" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-5">
<clipPath id="terminal-1053897658-line-5">
<rect x="0" y="123.5" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-6">
<clipPath id="terminal-1053897658-line-6">
<rect x="0" y="147.9" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-7">
<clipPath id="terminal-1053897658-line-7">
<rect x="0" y="172.3" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-8">
<clipPath id="terminal-1053897658-line-8">
<rect x="0" y="196.7" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-9">
<clipPath id="terminal-1053897658-line-9">
<rect x="0" y="221.1" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-10">
<clipPath id="terminal-1053897658-line-10">
<rect x="0" y="245.5" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-11">
<clipPath id="terminal-1053897658-line-11">
<rect x="0" y="269.9" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-12">
<clipPath id="terminal-1053897658-line-12">
<rect x="0" y="294.3" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-13">
<clipPath id="terminal-1053897658-line-13">
<rect x="0" y="318.7" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-14">
<clipPath id="terminal-1053897658-line-14">
<rect x="0" y="343.1" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-15">
<clipPath id="terminal-1053897658-line-15">
<rect x="0" y="367.5" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-16">
<clipPath id="terminal-1053897658-line-16">
<rect x="0" y="391.9" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-17">
<clipPath id="terminal-1053897658-line-17">
<rect x="0" y="416.3" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-18">
<clipPath id="terminal-1053897658-line-18">
<rect x="0" y="440.7" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-19">
<clipPath id="terminal-1053897658-line-19">
<rect x="0" y="465.1" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-20">
<clipPath id="terminal-1053897658-line-20">
<rect x="0" y="489.5" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-21">
<clipPath id="terminal-1053897658-line-21">
<rect x="0" y="513.9" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-22">
<clipPath id="terminal-1053897658-line-22">
<rect x="0" y="538.3" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1030366103-line-23">
<clipPath id="terminal-1053897658-line-23">
<rect x="0" y="562.7" width="683.2" height="24.65"/>
</clipPath>
<clipPath id="terminal-1053897658-line-24">
<rect x="0" y="587.1" width="683.2" height="24.65"/>
</clipPath>
</defs>
<rect fill="#1e1e2e" stroke="rgba(255,255,255,0.35)" stroke-width="1" x="10.1667" y="1" width="700" height="658" rx="8"/><text class="terminal-1030366103-title" fill="#c6d0f5" text-anchor="middle" x="350" 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="700" height="682.4" rx="8"/><text class="terminal-1053897658-title" fill="#c6d0f5" text-anchor="middle" x="350" 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-1030366103-clip-terminal)">
<g transform="translate(18.166666666666664, 41) scale(.95)" clip-path="url(#terminal-1053897658-clip-terminal)">
<g class="terminal-1030366103-matrix">
<text class="terminal-1030366103-r1" x="0" y="20" textLength="73.2" clip-path="url(#terminal-1030366103-line-0)">usage:</text><text class="terminal-1030366103-r2" x="683.2" y="20" textLength="12.2" clip-path="url(#terminal-1030366103-line-0)">
</text><text class="terminal-1030366103-r2" x="97.6" y="44.4" textLength="158.6" clip-path="url(#terminal-1030366103-line-1)">make&#160;&lt;recipe&gt;</text><text class="terminal-1030366103-r2" x="683.2" y="44.4" textLength="12.2" clip-path="url(#terminal-1030366103-line-1)">
</text><text class="terminal-1030366103-r2" x="683.2" y="68.8" textLength="12.2" clip-path="url(#terminal-1030366103-line-2)">
</text><text class="terminal-1030366103-r2" x="0" y="93.2" textLength="146.4" clip-path="url(#terminal-1030366103-line-3)">&#160;&#160;Turn&#160;your&#160;</text><text class="terminal-1030366103-r3" x="146.4" y="93.2" textLength="122" clip-path="url(#terminal-1030366103-line-3)">`Makefile`</text><text class="terminal-1030366103-r2" x="268.4" y="93.2" textLength="61" clip-path="url(#terminal-1030366103-line-3)">&#160;into</text><text class="terminal-1030366103-r2" x="683.2" y="93.2" textLength="12.2" clip-path="url(#terminal-1030366103-line-3)">
</text><text class="terminal-1030366103-r2" x="0" y="117.6" textLength="73.2" clip-path="url(#terminal-1030366103-line-4)">&#160;&#160;the&#160;</text><text class="terminal-1030366103-r4" x="73.2" y="117.6" textLength="134.2" clip-path="url(#terminal-1030366103-line-4)">task&#160;runner</text><text class="terminal-1030366103-r2" x="207.4" y="117.6" textLength="231.8" clip-path="url(#terminal-1030366103-line-4)">&#160;you&#160;always&#160;needed.</text><text class="terminal-1030366103-r2" x="683.2" y="117.6" textLength="12.2" clip-path="url(#terminal-1030366103-line-4)">
</text><text class="terminal-1030366103-r2" x="0" y="142" textLength="378.2" clip-path="url(#terminal-1030366103-line-5)">&#160;&#160;See&#160;the&#160;example&#160;output&#160;below.</text><text class="terminal-1030366103-r2" x="683.2" y="142" textLength="12.2" clip-path="url(#terminal-1030366103-line-5)">
</text><text class="terminal-1030366103-r2" x="683.2" y="166.4" textLength="12.2" clip-path="url(#terminal-1030366103-line-6)">
</text><text class="terminal-1030366103-r5" x="24.4" y="190.8" textLength="475.8" clip-path="url(#terminal-1030366103-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-1030366103-r2" x="683.2" y="190.8" textLength="12.2" clip-path="url(#terminal-1030366103-line-7)">
</text><text class="terminal-1030366103-r2" x="0" y="215.2" textLength="536.8" clip-path="url(#terminal-1030366103-line-8)">&#160;&#160;──────────────────────────────────────────</text><text class="terminal-1030366103-r2" x="683.2" y="215.2" textLength="12.2" clip-path="url(#terminal-1030366103-line-8)">
</text><text class="terminal-1030366103-r6" x="0" y="239.6" textLength="134.2" clip-path="url(#terminal-1030366103-line-9)">&#160;&#160;bootstrap</text><text class="terminal-1030366103-r2" x="134.2" y="239.6" textLength="36.6" clip-path="url(#terminal-1030366103-line-9)">&#160;&#160;</text><text class="terminal-1030366103-r7" x="170.8" y="239.6" textLength="366" clip-path="url(#terminal-1030366103-line-9)">generate&#160;local&#160;dev&#160;environment</text><text class="terminal-1030366103-r2" x="683.2" y="239.6" textLength="12.2" clip-path="url(#terminal-1030366103-line-9)">
</text><text class="terminal-1030366103-r6" x="0" y="264" textLength="134.2" clip-path="url(#terminal-1030366103-line-10)">&#160;&#160;&#160;&#160;l,&#160;lint</text><text class="terminal-1030366103-r2" x="134.2" y="264" textLength="36.6" clip-path="url(#terminal-1030366103-line-10)">&#160;&#160;</text><text class="terminal-1030366103-r7" x="170.8" y="264" textLength="183" clip-path="url(#terminal-1030366103-line-10)">lint&#160;the&#160;python</text><text class="terminal-1030366103-r2" x="683.2" y="264" textLength="12.2" clip-path="url(#terminal-1030366103-line-10)">
</text><text class="terminal-1030366103-r6" x="0" y="288.4" textLength="134.2" clip-path="url(#terminal-1030366103-line-11)">&#160;&#160;&#160;&#160;&#160;assets</text><text class="terminal-1030366103-r2" x="134.2" y="288.4" textLength="36.6" clip-path="url(#terminal-1030366103-line-11)">&#160;&#160;</text><text class="terminal-1030366103-r7" x="170.8" y="288.4" textLength="183" clip-path="url(#terminal-1030366103-line-11)">generate&#160;assets</text><text class="terminal-1030366103-r2" x="683.2" y="288.4" textLength="12.2" clip-path="url(#terminal-1030366103-line-11)">
</text><text class="terminal-1030366103-r6" x="0" y="312.8" textLength="134.2" clip-path="url(#terminal-1030366103-line-12)">&#160;&#160;&#160;&#160;release</text><text class="terminal-1030366103-r2" x="134.2" y="312.8" textLength="36.6" clip-path="url(#terminal-1030366103-line-12)">&#160;&#160;</text><text class="terminal-1030366103-r7" x="170.8" y="312.8" textLength="366" clip-path="url(#terminal-1030366103-line-12)">release&#160;new&#160;version&#160;of&#160;task.mk</text><text class="terminal-1030366103-r2" x="683.2" y="312.8" textLength="12.2" clip-path="url(#terminal-1030366103-line-12)">
</text><text class="terminal-1030366103-r6" x="0" y="337.2" textLength="134.2" clip-path="url(#terminal-1030366103-line-13)">&#160;&#160;&#160;c,&#160;clean</text><text class="terminal-1030366103-r2" x="134.2" y="337.2" textLength="36.6" clip-path="url(#terminal-1030366103-line-13)">&#160;&#160;</text><text class="terminal-1030366103-r7" x="170.8" y="337.2" textLength="317.2" clip-path="url(#terminal-1030366103-line-13)">remove&#160;the&#160;generated&#160;files</text><text class="terminal-1030366103-r2" x="683.2" y="337.2" textLength="12.2" clip-path="url(#terminal-1030366103-line-13)">
</text><text class="terminal-1030366103-r2" x="0" y="361.6" textLength="536.8" clip-path="url(#terminal-1030366103-line-14)">&#160;&#160;──────────────────────────────────────────</text><text class="terminal-1030366103-r2" x="683.2" y="361.6" textLength="12.2" clip-path="url(#terminal-1030366103-line-14)">
</text><text class="terminal-1030366103-r2" x="683.2" y="386" textLength="12.2" clip-path="url(#terminal-1030366103-line-15)">
</text><text class="terminal-1030366103-r8" x="24.4" y="410.4" textLength="475.8" clip-path="url(#terminal-1030366103-line-16)">&#160;&#160;&#160;&#160;&#160;&#160;examples&#160;of&#160;task.mk&#160;features&#160;&#160;&#160;&#160;&#160;</text><text class="terminal-1030366103-r2" x="683.2" y="410.4" textLength="12.2" clip-path="url(#terminal-1030366103-line-16)">
</text><text class="terminal-1030366103-r2" x="0" y="434.8" textLength="536.8" clip-path="url(#terminal-1030366103-line-17)">&#160;&#160;──────────────────────────────────────────</text><text class="terminal-1030366103-r2" x="683.2" y="434.8" textLength="12.2" clip-path="url(#terminal-1030366103-line-17)">
</text><text class="terminal-1030366103-r6" x="0" y="459.2" textLength="134.2" clip-path="url(#terminal-1030366103-line-18)">&#160;&#160;&#160;&#160;&#160;list-%</text><text class="terminal-1030366103-r2" x="134.2" y="459.2" textLength="36.6" clip-path="url(#terminal-1030366103-line-18)">&#160;&#160;</text><text class="terminal-1030366103-r7" x="170.8" y="459.2" textLength="366" clip-path="url(#terminal-1030366103-line-18)">use&#160;pathlib.Path&#160;to&#160;list&#160;files</text><text class="terminal-1030366103-r2" x="683.2" y="459.2" textLength="12.2" clip-path="url(#terminal-1030366103-line-18)">
</text><text class="terminal-1030366103-r7" x="170.8" y="483.6" textLength="512.4" clip-path="url(#terminal-1030366103-line-19)">name&#160;the&#160;directory&#160;in&#160;rule&#160;(make&#160;list-src)</text><text class="terminal-1030366103-r2" x="683.2" y="483.6" textLength="12.2" clip-path="url(#terminal-1030366103-line-19)">
</text><text class="terminal-1030366103-r6" x="0" y="508" textLength="134.2" clip-path="url(#terminal-1030366103-line-20)">&#160;&#160;&#160;&#160;&#160;&#160;&#160;info</text><text class="terminal-1030366103-r2" x="134.2" y="508" textLength="36.6" clip-path="url(#terminal-1030366103-line-20)">&#160;&#160;</text><text class="terminal-1030366103-r7" x="170.8" y="508" textLength="329.4" clip-path="url(#terminal-1030366103-line-20)">demonstrate&#160;usage&#160;of&#160;tprint</text><text class="terminal-1030366103-r2" x="683.2" y="508" textLength="12.2" clip-path="url(#terminal-1030366103-line-20)">
</text><text class="terminal-1030366103-r2" x="0" y="532.4" textLength="536.8" clip-path="url(#terminal-1030366103-line-21)">&#160;&#160;──────────────────────────────────────────</text><text class="terminal-1030366103-r2" x="683.2" y="532.4" textLength="12.2" clip-path="url(#terminal-1030366103-line-21)">
</text><text class="terminal-1030366103-r6" x="0" y="556.8" textLength="134.2" clip-path="url(#terminal-1030366103-line-22)">&#160;&#160;&#160;&#160;h,&#160;help</text><text class="terminal-1030366103-r2" x="134.2" y="556.8" textLength="36.6" clip-path="url(#terminal-1030366103-line-22)">&#160;&#160;</text><text class="terminal-1030366103-r7" x="170.8" y="556.8" textLength="170.8" clip-path="url(#terminal-1030366103-line-22)">show&#160;this&#160;help</text><text class="terminal-1030366103-r2" x="683.2" y="556.8" textLength="12.2" clip-path="url(#terminal-1030366103-line-22)">
</text><text class="terminal-1030366103-r2" x="683.2" y="581.2" textLength="12.2" clip-path="url(#terminal-1030366103-line-23)">
</text><text class="terminal-1030366103-r2" x="0" y="605.6" textLength="561.2" clip-path="url(#terminal-1030366103-line-24)">for&#160;more&#160;info:&#160;github.com/daylinmorgan/task.mk</text><text class="terminal-1030366103-r2" x="683.2" y="605.6" textLength="12.2" clip-path="url(#terminal-1030366103-line-24)">
<g class="terminal-1053897658-matrix">
<text class="terminal-1053897658-r1" x="0" y="20" textLength="73.2" clip-path="url(#terminal-1053897658-line-0)">usage:</text><text class="terminal-1053897658-r2" x="683.2" y="20" textLength="12.2" clip-path="url(#terminal-1053897658-line-0)">
</text><text class="terminal-1053897658-r2" x="97.6" y="44.4" textLength="158.6" clip-path="url(#terminal-1053897658-line-1)">make&#160;&lt;recipe&gt;</text><text class="terminal-1053897658-r2" x="683.2" y="44.4" textLength="12.2" clip-path="url(#terminal-1053897658-line-1)">
</text><text class="terminal-1053897658-r2" x="683.2" y="68.8" textLength="12.2" clip-path="url(#terminal-1053897658-line-2)">
</text><text class="terminal-1053897658-r2" x="0" y="93.2" textLength="146.4" clip-path="url(#terminal-1053897658-line-3)">&#160;&#160;Turn&#160;your&#160;</text><text class="terminal-1053897658-r3" x="146.4" y="93.2" textLength="122" clip-path="url(#terminal-1053897658-line-3)">`Makefile`</text><text class="terminal-1053897658-r2" x="268.4" y="93.2" textLength="61" clip-path="url(#terminal-1053897658-line-3)">&#160;into</text><text class="terminal-1053897658-r2" x="683.2" y="93.2" textLength="12.2" clip-path="url(#terminal-1053897658-line-3)">
</text><text class="terminal-1053897658-r2" x="0" y="117.6" textLength="73.2" clip-path="url(#terminal-1053897658-line-4)">&#160;&#160;the&#160;</text><text class="terminal-1053897658-r4" x="73.2" y="117.6" textLength="134.2" clip-path="url(#terminal-1053897658-line-4)">task&#160;runner</text><text class="terminal-1053897658-r2" x="207.4" y="117.6" textLength="231.8" clip-path="url(#terminal-1053897658-line-4)">&#160;you&#160;always&#160;needed.</text><text class="terminal-1053897658-r2" x="683.2" y="117.6" textLength="12.2" clip-path="url(#terminal-1053897658-line-4)">
</text><text class="terminal-1053897658-r2" x="0" y="142" textLength="378.2" clip-path="url(#terminal-1053897658-line-5)">&#160;&#160;See&#160;the&#160;example&#160;output&#160;below.</text><text class="terminal-1053897658-r2" x="683.2" y="142" textLength="12.2" clip-path="url(#terminal-1053897658-line-5)">
</text><text class="terminal-1053897658-r2" x="683.2" y="166.4" textLength="12.2" clip-path="url(#terminal-1053897658-line-6)">
</text><text class="terminal-1053897658-r5" x="24.4" y="190.8" textLength="475.8" clip-path="url(#terminal-1053897658-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-1053897658-r2" x="683.2" y="190.8" textLength="12.2" clip-path="url(#terminal-1053897658-line-7)">
</text><text class="terminal-1053897658-r2" x="0" y="215.2" textLength="536.8" clip-path="url(#terminal-1053897658-line-8)">&#160;&#160;──────────────────────────────────────────</text><text class="terminal-1053897658-r2" x="683.2" y="215.2" textLength="12.2" clip-path="url(#terminal-1053897658-line-8)">
</text><text class="terminal-1053897658-r6" x="0" y="239.6" textLength="134.2" clip-path="url(#terminal-1053897658-line-9)">&#160;&#160;bootstrap</text><text class="terminal-1053897658-r2" x="134.2" y="239.6" textLength="36.6" clip-path="url(#terminal-1053897658-line-9)">&#160;&#160;</text><text class="terminal-1053897658-r7" x="170.8" y="239.6" textLength="366" clip-path="url(#terminal-1053897658-line-9)">generate&#160;local&#160;dev&#160;environment</text><text class="terminal-1053897658-r2" x="683.2" y="239.6" textLength="12.2" clip-path="url(#terminal-1053897658-line-9)">
</text><text class="terminal-1053897658-r6" x="0" y="264" textLength="134.2" clip-path="url(#terminal-1053897658-line-10)">&#160;&#160;&#160;&#160;l,&#160;lint</text><text class="terminal-1053897658-r2" x="134.2" y="264" textLength="36.6" clip-path="url(#terminal-1053897658-line-10)">&#160;&#160;</text><text class="terminal-1053897658-r7" x="170.8" y="264" textLength="183" clip-path="url(#terminal-1053897658-line-10)">lint&#160;the&#160;python</text><text class="terminal-1053897658-r2" x="683.2" y="264" textLength="12.2" clip-path="url(#terminal-1053897658-line-10)">
</text><text class="terminal-1053897658-r6" x="0" y="288.4" textLength="134.2" clip-path="url(#terminal-1053897658-line-11)">&#160;&#160;&#160;&#160;&#160;assets</text><text class="terminal-1053897658-r2" x="134.2" y="288.4" textLength="36.6" clip-path="url(#terminal-1053897658-line-11)">&#160;&#160;</text><text class="terminal-1053897658-r7" x="170.8" y="288.4" textLength="183" clip-path="url(#terminal-1053897658-line-11)">generate&#160;assets</text><text class="terminal-1053897658-r2" x="683.2" y="288.4" textLength="12.2" clip-path="url(#terminal-1053897658-line-11)">
</text><text class="terminal-1053897658-r6" x="0" y="312.8" textLength="134.2" clip-path="url(#terminal-1053897658-line-12)">&#160;&#160;&#160;&#160;release</text><text class="terminal-1053897658-r2" x="134.2" y="312.8" textLength="36.6" clip-path="url(#terminal-1053897658-line-12)">&#160;&#160;</text><text class="terminal-1053897658-r7" x="170.8" y="312.8" textLength="366" clip-path="url(#terminal-1053897658-line-12)">release&#160;new&#160;version&#160;of&#160;task.mk</text><text class="terminal-1053897658-r2" x="683.2" y="312.8" textLength="12.2" clip-path="url(#terminal-1053897658-line-12)">
</text><text class="terminal-1053897658-r6" x="0" y="337.2" textLength="134.2" clip-path="url(#terminal-1053897658-line-13)">&#160;&#160;&#160;c,&#160;clean</text><text class="terminal-1053897658-r2" x="134.2" y="337.2" textLength="36.6" clip-path="url(#terminal-1053897658-line-13)">&#160;&#160;</text><text class="terminal-1053897658-r7" x="170.8" y="337.2" textLength="317.2" clip-path="url(#terminal-1053897658-line-13)">remove&#160;the&#160;generated&#160;files</text><text class="terminal-1053897658-r2" x="683.2" y="337.2" textLength="12.2" clip-path="url(#terminal-1053897658-line-13)">
</text><text class="terminal-1053897658-r2" x="0" y="361.6" textLength="536.8" clip-path="url(#terminal-1053897658-line-14)">&#160;&#160;──────────────────────────────────────────</text><text class="terminal-1053897658-r2" x="683.2" y="361.6" textLength="12.2" clip-path="url(#terminal-1053897658-line-14)">
</text><text class="terminal-1053897658-r2" x="683.2" y="386" textLength="12.2" clip-path="url(#terminal-1053897658-line-15)">
</text><text class="terminal-1053897658-r8" x="24.4" y="410.4" textLength="475.8" clip-path="url(#terminal-1053897658-line-16)">&#160;&#160;&#160;&#160;&#160;&#160;examples&#160;of&#160;task.mk&#160;features&#160;&#160;&#160;&#160;&#160;</text><text class="terminal-1053897658-r2" x="683.2" y="410.4" textLength="12.2" clip-path="url(#terminal-1053897658-line-16)">
</text><text class="terminal-1053897658-r2" x="0" y="434.8" textLength="536.8" clip-path="url(#terminal-1053897658-line-17)">&#160;&#160;──────────────────────────────────────────</text><text class="terminal-1053897658-r2" x="683.2" y="434.8" textLength="12.2" clip-path="url(#terminal-1053897658-line-17)">
</text><text class="terminal-1053897658-r6" x="0" y="459.2" textLength="134.2" clip-path="url(#terminal-1053897658-line-18)">&#160;&#160;&#160;&#160;&#160;list-%</text><text class="terminal-1053897658-r2" x="134.2" y="459.2" textLength="36.6" clip-path="url(#terminal-1053897658-line-18)">&#160;&#160;</text><text class="terminal-1053897658-r7" x="170.8" y="459.2" textLength="366" clip-path="url(#terminal-1053897658-line-18)">use&#160;pathlib.Path&#160;to&#160;list&#160;files</text><text class="terminal-1053897658-r2" x="683.2" y="459.2" textLength="12.2" clip-path="url(#terminal-1053897658-line-18)">
</text><text class="terminal-1053897658-r7" x="170.8" y="483.6" textLength="512.4" clip-path="url(#terminal-1053897658-line-19)">name&#160;the&#160;directory&#160;in&#160;rule&#160;(make&#160;list-src)</text><text class="terminal-1053897658-r2" x="683.2" y="483.6" textLength="12.2" clip-path="url(#terminal-1053897658-line-19)">
</text><text class="terminal-1053897658-r6" x="0" y="508" textLength="134.2" clip-path="url(#terminal-1053897658-line-20)">&#160;&#160;&#160;&#160;&#160;&#160;&#160;info</text><text class="terminal-1053897658-r2" x="134.2" y="508" textLength="36.6" clip-path="url(#terminal-1053897658-line-20)">&#160;&#160;</text><text class="terminal-1053897658-r7" x="170.8" y="508" textLength="329.4" clip-path="url(#terminal-1053897658-line-20)">demonstrate&#160;usage&#160;of&#160;tprint</text><text class="terminal-1053897658-r2" x="683.2" y="508" textLength="12.2" clip-path="url(#terminal-1053897658-line-20)">
</text><text class="terminal-1053897658-r6" x="0" y="532.4" textLength="134.2" clip-path="url(#terminal-1053897658-line-21)">&#160;&#160;&#160;&#160;&#160;&#160;check</text><text class="terminal-1053897658-r2" x="134.2" y="532.4" textLength="36.6" clip-path="url(#terminal-1053897658-line-21)">&#160;&#160;</text><text class="terminal-1053897658-r7" x="170.8" y="532.4" textLength="353.8" clip-path="url(#terminal-1053897658-line-21)">get&#160;user&#160;confirmation&#160;or&#160;exit</text><text class="terminal-1053897658-r2" x="683.2" y="532.4" textLength="12.2" clip-path="url(#terminal-1053897658-line-21)">
</text><text class="terminal-1053897658-r2" x="0" y="556.8" textLength="536.8" clip-path="url(#terminal-1053897658-line-22)">&#160;&#160;──────────────────────────────────────────</text><text class="terminal-1053897658-r2" x="683.2" y="556.8" textLength="12.2" clip-path="url(#terminal-1053897658-line-22)">
</text><text class="terminal-1053897658-r6" x="0" y="581.2" textLength="134.2" clip-path="url(#terminal-1053897658-line-23)">&#160;&#160;&#160;&#160;h,&#160;help</text><text class="terminal-1053897658-r2" x="134.2" y="581.2" textLength="36.6" clip-path="url(#terminal-1053897658-line-23)">&#160;&#160;</text><text class="terminal-1053897658-r7" x="170.8" y="581.2" textLength="170.8" clip-path="url(#terminal-1053897658-line-23)">show&#160;this&#160;help</text><text class="terminal-1053897658-r2" x="683.2" y="581.2" textLength="12.2" clip-path="url(#terminal-1053897658-line-23)">
</text><text class="terminal-1053897658-r2" x="683.2" y="605.6" textLength="12.2" clip-path="url(#terminal-1053897658-line-24)">
</text><text class="terminal-1053897658-r2" x="0" y="630" textLength="561.2" clip-path="url(#terminal-1053897658-line-25)">for&#160;more&#160;info:&#160;github.com/daylinmorgan/task.mk</text><text class="terminal-1053897658-r2" x="683.2" y="630" textLength="12.2" clip-path="url(#terminal-1053897658-line-25)">
</text>
</g>
</g>

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -5,7 +5,7 @@ from pathlib import Path
import jinja2
py_script_names = ["help", "ansi", "info", "print-ansi", "vars"]
py_script_names = ["help", "ansi", "info", "print-ansi", "vars","confirm"]
def get_jinja_env():

View file

@ -1,6 +1,5 @@
# ---- [buitlin recipes] ---- #
## h, help | show this help
.PHONY: help h
help h:
@ -20,6 +19,8 @@ vars v:
endif
### | args: -ws --hidden
### task.mk builtins: | args: -d --hidden
## _print-ansi | show all possible ansi color code combinations
.PHONY:
_print-ansi:
@ -29,8 +30,11 @@ _print-ansi:
tprint = $(call py,info_py,$(1))
tprint-sh = $(call pysh,info_py,$(1))
tconfirm = $(call py,confirm_py,$(1))
## _update-task.mk | downloads latest development version of task.mk
_update-task.mk:
$(call tprint,Updating task.mk)
$(call tprint,{a.b_cyan}Updating task.mk{a.end})
curl https://raw.githubusercontent.com/daylinmorgan/task.mk/main/task.mk -o .task.mk
export MAKEFILE_LIST

23
src/confirm.py Normal file
View file

@ -0,0 +1,23 @@
#% extends "py-script.mk" %#
#% block name %#confirm#% endblock %#
#% block script %#
import sys
##- '$(ansi_py)' -##
def confirm():
"""
Ask user to enter Y or N (case-insensitive).
:return: True if the answer is Y.
:rtype: bool
"""
answer = ""
while answer not in ["y", "n"]:
answer = input(f"""$(2) {a.b_red}[Y/n]{a.end} """).lower()
return answer == "y"
if confirm():
sys.exit(0)
else:
sys.exit(1)
#% endblock %#

View file

@ -3,6 +3,6 @@
# MIT License
# version: ##- version -##
#
# task.mk should be included at the bottom of your Makefile.
# 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

@ -25,6 +25,7 @@ def rawargs(argstring):
parser.add_argument("-d", "--divider", action="store_true")
parser.add_argument("-ws", "--whitespace", action="store_true")
parser.add_argument("-ms", "--msg-style", type=str)
parser.add_argument("--hidden",action="store_true")
return parser.parse_args(argstring.split())
@ -59,6 +60,8 @@ def print_goal(goal, msg, max_goal_len):
def print_rawmsg(msg, argstr, maxlens):
args = rawargs(argstr)
msg_style = args.msg_style if args.msg_style else "$(MSG_COLOR)"
if not os.getenv("SHOW_HIDDEN") and args.hidden:
return
if msg:
if args.align == "sep":
print(

View file

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

View file

@ -13,16 +13,16 @@ create_string = $(subst $(\n),\n,$(call escape_shellstring,$(call escape_printf,
ifdef DEBUG
define _debug_runner
@printf "$(1) Script:\n"
@printf -- "<---------------->\n"
@printf -- "<----------------------------------->\n"
@printf "$(call create_string,$(3))\n"
@printf -- "<---------------->\n"
@printf -- "<----------------------------------->\n"
@printf "$(call create_string,$(3))" | $(2)
endef
py = $(call _debug_runner,Python,python3,$($(1)))
tbash = $(call _debug_runner,Bash,bash,$($(1)))
else
py = @printf "$(call create_string,$($(1)))" | python3
tbash = @printf "$(call create_string,$($(1)))" | bash
py = @python3 <(printf "$(call create_string,$($(1)))")
tbash = @bash <(printf "$(call create_string,$($(1)))")
endif
pysh = printf "$(call create_string,$($(1)))" | python3
pysh = python3 <(printf "$(call create_string,$($(1)))")

51
task.mk
View file

@ -1,9 +1,9 @@
# }> [github.com/daylinmorgan/task.mk] <{ #
# Copyright (c) 2022 Daylin Morgan
# MIT License
# version: 22.9.14
# version: v22.9.14-4-gde1bc7e-dev
#
# task.mk should be included at the bottom of your Makefile.
# 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`
@ -27,7 +27,6 @@ endef
# ---- [buitlin recipes] ---- #
## h, help | show this help
.PHONY: help h
help h:
@ -47,6 +46,8 @@ vars v:
endif
### | args: -ws --hidden
### task.mk builtins: | args: -d --hidden
## _print-ansi | show all possible ansi color code combinations
.PHONY:
_print-ansi:
@ -56,8 +57,11 @@ _print-ansi:
tprint = $(call py,info_py,$(1))
tprint-sh = $(call pysh,info_py,$(1))
tconfirm = $(call py,confirm_py,$(1))
## _update-task.mk | downloads latest development version of task.mk
_update-task.mk:
$(call tprint,Updating task.mk)
$(call tprint,{a.b_cyan}Updating task.mk{a.end})
curl https://raw.githubusercontent.com/daylinmorgan/task.mk/main/task.mk -o .task.mk
export MAKEFILE_LIST
@ -77,19 +81,19 @@ create_string = $(subst $(\n),\n,$(call escape_shellstring,$(call escape_printf,
ifdef DEBUG
define _debug_runner
@printf "$(1) Script:\n"
@printf -- "<---------------->\n"
@printf -- "<----------------------------------->\n"
@printf "$(call create_string,$(3))\n"
@printf -- "<---------------->\n"
@printf -- "<----------------------------------->\n"
@printf "$(call create_string,$(3))" | $(2)
endef
py = $(call _debug_runner,Python,python3,$($(1)))
tbash = $(call _debug_runner,Bash,bash,$($(1)))
else
py = @printf "$(call create_string,$($(1)))" | python3
tbash = @printf "$(call create_string,$($(1)))" | bash
py = @python3 <(printf "$(call create_string,$($(1)))")
tbash = @bash <(printf "$(call create_string,$($(1)))")
endif
pysh = printf "$(call create_string,$($(1)))" | python3
pysh = python3 <(printf "$(call create_string,$($(1)))")
# ---- [python scripts] ---- #
@ -120,6 +124,7 @@ def rawargs(argstring):
parser.add_argument("-d", "--divider", action="store_true")
parser.add_argument("-ws", "--whitespace", action="store_true")
parser.add_argument("-ms", "--msg-style", type=str)
parser.add_argument("--hidden",action="store_true")
return parser.parse_args(argstring.split())
@ -154,6 +159,8 @@ def print_goal(goal, msg, max_goal_len):
def print_rawmsg(msg, argstr, maxlens):
args = rawargs(argstr)
msg_style = args.msg_style if args.msg_style else "$(MSG_COLOR)"
if not os.getenv("SHOW_HIDDEN") and args.hidden:
return
if msg:
if args.align == "sep":
print(
@ -302,7 +309,7 @@ $(ansi_py)
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} {}".format(codes_names[code], code + "******" + ansi.end))
print("{:>20} $(HELP_SEP) {} $(HELP_SEP) {}".format(codes_names[code], code + "******" + ansi.end,repr(code)))
endef
@ -325,3 +332,27 @@ print()
endef
define confirm_py
import sys
$(ansi_py)
def confirm():
"""
Ask user to enter Y or N (case-insensitive).
:return: True if the answer is Y.
:rtype: bool
"""
answer = ""
while answer not in ["y", "n"]:
answer = input(f"""$(2) {a.b_red}[Y/n]{a.end} """).lower()
return answer == "y"
if confirm():
sys.exit(0)
else:
sys.exit(1)
endef