mirror of
https://github.com/daylinmorgan/task.mk.git
synced 2024-12-22 18:00:44 -06:00
Compare commits
No commits in common. "ea85b2378ef7c92a9332eeafad4ca27159d16b6f" and "f62def68fc04eeedb2b7f23e63073733ed987171" have entirely different histories.
ea85b2378e
...
f62def68fc
8 changed files with 136 additions and 312 deletions
45
Makefile
45
Makefile
|
@ -2,10 +2,8 @@ VERSION ?= $(shell git describe --tags --always --dirty | sed s'/dirty/dev/')
|
|||
TEMPLATES := $(shell find src/ -type f)
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
msgfmt = {a.style('==>','bold')} {a.style('$(1)','b_magenta')} {a.style('<==','bold')}
|
||||
msg = $(call tprint,$(call msgfmt ,$(1)))
|
||||
msg = $(call tprint,{a.bold}==>{a.end} {a.magenta}$(1){a.end} {a.bold}<=={a.end})
|
||||
|
||||
### task.mk development | args: -d -ms b_green --align center
|
||||
## bootstrap | generate local dev environment
|
||||
.PHONY: bootstrap
|
||||
bootstrap:
|
||||
|
@ -14,17 +12,26 @@ bootstrap:
|
|||
@mamba run -p ./env pip install yartsu
|
||||
@git config core.hooksPath .githooks
|
||||
|
||||
## l, lint | lint the python
|
||||
.PHONY: l lint
|
||||
l lint:
|
||||
$(call msg,Linting)
|
||||
## lint | lint the python
|
||||
.PHONY: lint
|
||||
lint:
|
||||
@black generate.py
|
||||
@black src/*.py --fast
|
||||
|
||||
## assets | generate assets
|
||||
.PHONY: assets
|
||||
assets:
|
||||
@yartsu -o assets/help.svg -t "make help" -- make --no-print-directory help
|
||||
yartsu -o assets/help.svg -t "make help" -- make --no-print-directory help
|
||||
|
||||
define list_files_py
|
||||
from pathlib import Path
|
||||
print("files in $(2)")
|
||||
print([f.name for f in (Path("$(2)").iterdir())])
|
||||
endef
|
||||
|
||||
## list-% | use pathlib.Path to list files
|
||||
list-%:
|
||||
$(call py,list_files_py,$*)
|
||||
|
||||
## release | release new version of task.mk
|
||||
.PHONY: release
|
||||
|
@ -41,19 +48,6 @@ release: version-check
|
|||
c clean:
|
||||
@rm -f task.mk .task.mk
|
||||
|
||||
### | args: --divider --whitespace
|
||||
### examples of task.mk features | args: --divider --align center --msg-style b_red
|
||||
define list_files_py
|
||||
from pathlib import Path
|
||||
print("files in $(2)")
|
||||
print([f.name for f in (Path("$(2)").iterdir())])
|
||||
endef
|
||||
|
||||
## list-% | use pathlib.Path to list files
|
||||
### name the directory in rule (make list-src) | args: --align sep
|
||||
list-%:
|
||||
$(call py,list_files_py,$*)
|
||||
|
||||
.PHONY: version-check
|
||||
version-check:
|
||||
@if [[ "${VERSION}" == *'-'* ]]; then\
|
||||
|
@ -76,10 +70,11 @@ endef
|
|||
test-bash:
|
||||
$(call tbash,bash_script,test bash multiline)
|
||||
|
||||
|
||||
define mlmsg
|
||||
{a.b_yellow}
|
||||
It can even be multiline!{a.end}
|
||||
{a.style('and styles can be defined','red')}
|
||||
and styles can be defined{a.end}
|
||||
as python {a.bold}f-string{a.end} literals
|
||||
{a.end}
|
||||
endef
|
||||
|
@ -92,8 +87,6 @@ info:
|
|||
$(call tprint,$(mlmsg))
|
||||
$(call tprint,{a.custom(fg=(148, 255, 15),bg=(103, 2, 15))}Custom Colors TOO!{a.end})
|
||||
|
||||
### | args: --divider
|
||||
|
||||
task.mk: $(TEMPLATES) generate.py
|
||||
./generate.py $(VERSION) > task.mk
|
||||
|
||||
|
@ -101,7 +94,7 @@ define USAGE
|
|||
{a.$(HEADER_COLOR)}usage:{a.end}
|
||||
make <recipe>
|
||||
|
||||
Turn your {a.style('`Makefile`','b_magenta')} into
|
||||
Turn your {a.b_magenta}`Makefile`{a.end} into
|
||||
the {a.italic}{a.underline}task runner{a.end} you always needed.
|
||||
See the example output below.
|
||||
|
||||
|
@ -112,4 +105,4 @@ PRINT_VARS := VERSION
|
|||
|
||||
-include .task.mk
|
||||
.task.mk: $(TEMPLATES) generate.py
|
||||
@./generate.py $(VERSION) > .task.mk || (echo "generator failed!!" && rm .task.mk)
|
||||
./generate.py $(VERSION) > .task.mk
|
||||
|
|
|
@ -21,8 +21,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`](./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.
|
||||
I agree, so I've hacked together a file containing the bits of python we need with some tricks to run it.
|
||||
|
||||
## Setup
|
||||
|
||||
|
@ -31,14 +30,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.12/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.12/task.mk -o .task.mk)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
|
160
assets/help.svg
160
assets/help.svg
|
@ -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 598.3333333333334 497.13333333333327" 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-3542066451-matrix {
|
||||
font-family: Fira Code, monospace;
|
||||
font-size: 20px;
|
||||
line-height: 24.4px;
|
||||
font-variant-east-asian: full-width;
|
||||
}
|
||||
|
||||
.terminal-1030366103-title {
|
||||
.terminal-3542066451-title {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
font-family: arial;
|
||||
|
@ -33,129 +33,95 @@
|
|||
-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-3542066451-r1 { fill: #94e2d5;font-weight: bold }
|
||||
.terminal-3542066451-r2 { fill: #c6d0f5 }
|
||||
.terminal-3542066451-r3 { fill: #f5c2e7;font-weight: bold }
|
||||
.terminal-3542066451-r4 { fill: #c6d0f5;font-style: italic;;text-decoration: underline; }
|
||||
.terminal-3542066451-r5 { fill: #f9e2af;font-weight: bold }
|
||||
.terminal-3542066451-r6 { fill: #8288a5 }
|
||||
</style>
|
||||
|
||||
<defs>
|
||||
<clipPath id="terminal-1030366103-clip-terminal">
|
||||
<rect x="0" y="0" width="682.1999999999999" height="609.0" />
|
||||
<clipPath id="terminal-3542066451-clip-terminal">
|
||||
<rect x="0" y="0" width="560.1999999999999" height="413.79999999999995" />
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-0">
|
||||
<rect x="0" y="1.5" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-0">
|
||||
<rect x="0" y="1.5" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-1">
|
||||
<rect x="0" y="25.9" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-1">
|
||||
<rect x="0" y="25.9" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-2">
|
||||
<rect x="0" y="50.3" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-2">
|
||||
<rect x="0" y="50.3" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-3">
|
||||
<rect x="0" y="74.7" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-3">
|
||||
<rect x="0" y="74.7" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-4">
|
||||
<rect x="0" y="99.1" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-4">
|
||||
<rect x="0" y="99.1" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-5">
|
||||
<rect x="0" y="123.5" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-5">
|
||||
<rect x="0" y="123.5" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-6">
|
||||
<rect x="0" y="147.9" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-6">
|
||||
<rect x="0" y="147.9" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-7">
|
||||
<rect x="0" y="172.3" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-7">
|
||||
<rect x="0" y="172.3" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-8">
|
||||
<rect x="0" y="196.7" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-8">
|
||||
<rect x="0" y="196.7" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-9">
|
||||
<rect x="0" y="221.1" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-9">
|
||||
<rect x="0" y="221.1" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-10">
|
||||
<rect x="0" y="245.5" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-10">
|
||||
<rect x="0" y="245.5" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-11">
|
||||
<rect x="0" y="269.9" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-11">
|
||||
<rect x="0" y="269.9" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-12">
|
||||
<rect x="0" y="294.3" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-12">
|
||||
<rect x="0" y="294.3" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-13">
|
||||
<rect x="0" y="318.7" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-13">
|
||||
<rect x="0" y="318.7" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-14">
|
||||
<rect x="0" y="343.1" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-14">
|
||||
<rect x="0" y="343.1" width="561.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-15">
|
||||
<rect x="0" y="367.5" width="683.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-16">
|
||||
<rect x="0" y="391.9" width="683.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-17">
|
||||
<rect x="0" y="416.3" width="683.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-18">
|
||||
<rect x="0" y="440.7" width="683.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-19">
|
||||
<rect x="0" y="465.1" width="683.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-20">
|
||||
<rect x="0" y="489.5" width="683.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-21">
|
||||
<rect x="0" y="513.9" width="683.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-22">
|
||||
<rect x="0" y="538.3" width="683.2" height="24.65"/>
|
||||
</clipPath>
|
||||
<clipPath id="terminal-1030366103-line-23">
|
||||
<rect x="0" y="562.7" width="683.2" height="24.65"/>
|
||||
<clipPath id="terminal-3542066451-line-15">
|
||||
<rect x="0" y="367.5" width="561.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 help</text>
|
||||
<rect fill="#1e1e2e" stroke="rgba(255,255,255,0.35)" stroke-width="1" x="10.1667" y="1" width="578" height="462.8" rx="8"/><text class="terminal-3542066451-title" fill="#c6d0f5" text-anchor="middle" x="289" y="27">make 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-3542066451-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 <recipe></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)">  Turn your </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)"> 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)">  the </text><text class="terminal-1030366103-r4" x="73.2" y="117.6" textLength="134.2" clip-path="url(#terminal-1030366103-line-4)">task runner</text><text class="terminal-1030366103-r2" x="207.4" y="117.6" textLength="231.8" clip-path="url(#terminal-1030366103-line-4)"> you always 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)">  See the example output 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)">          task.mk development          </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)">  ──────────────────────────────────────────</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)">  bootstrap</text><text class="terminal-1030366103-r2" x="134.2" y="239.6" textLength="36.6" clip-path="url(#terminal-1030366103-line-9)"> │ </text><text class="terminal-1030366103-r7" x="170.8" y="239.6" textLength="366" clip-path="url(#terminal-1030366103-line-9)">generate local dev 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)">    l, lint</text><text class="terminal-1030366103-r2" x="134.2" y="264" textLength="36.6" clip-path="url(#terminal-1030366103-line-10)"> │ </text><text class="terminal-1030366103-r7" x="170.8" y="264" textLength="183" clip-path="url(#terminal-1030366103-line-10)">lint the 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)">     assets</text><text class="terminal-1030366103-r2" x="134.2" y="288.4" textLength="36.6" clip-path="url(#terminal-1030366103-line-11)"> │ </text><text class="terminal-1030366103-r7" x="170.8" y="288.4" textLength="183" clip-path="url(#terminal-1030366103-line-11)">generate 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)">    release</text><text class="terminal-1030366103-r2" x="134.2" y="312.8" textLength="36.6" clip-path="url(#terminal-1030366103-line-12)"> │ </text><text class="terminal-1030366103-r7" x="170.8" y="312.8" textLength="366" clip-path="url(#terminal-1030366103-line-12)">release new version of 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)">   c, clean</text><text class="terminal-1030366103-r2" x="134.2" y="337.2" textLength="36.6" clip-path="url(#terminal-1030366103-line-13)"> │ </text><text class="terminal-1030366103-r7" x="170.8" y="337.2" textLength="317.2" clip-path="url(#terminal-1030366103-line-13)">remove the generated 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)">  ──────────────────────────────────────────</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)">      examples of task.mk features     </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)">  ──────────────────────────────────────────</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)">     list-%</text><text class="terminal-1030366103-r2" x="134.2" y="459.2" textLength="36.6" clip-path="url(#terminal-1030366103-line-18)"> │ </text><text class="terminal-1030366103-r7" x="170.8" y="459.2" textLength="366" clip-path="url(#terminal-1030366103-line-18)">use pathlib.Path to list 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 the directory in rule (make 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)">       info</text><text class="terminal-1030366103-r2" x="134.2" y="508" textLength="36.6" clip-path="url(#terminal-1030366103-line-20)"> │ </text><text class="terminal-1030366103-r7" x="170.8" y="508" textLength="329.4" clip-path="url(#terminal-1030366103-line-20)">demonstrate usage of 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)">  ──────────────────────────────────────────</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)">    h, help</text><text class="terminal-1030366103-r2" x="134.2" y="556.8" textLength="36.6" clip-path="url(#terminal-1030366103-line-22)"> │ </text><text class="terminal-1030366103-r7" x="170.8" y="556.8" textLength="170.8" clip-path="url(#terminal-1030366103-line-22)">show this 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 more info: 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-3542066451-matrix">
|
||||
<text class="terminal-3542066451-r1" x="0" y="20" textLength="73.2" clip-path="url(#terminal-3542066451-line-0)">usage:</text><text class="terminal-3542066451-r2" x="561.2" y="20" textLength="12.2" clip-path="url(#terminal-3542066451-line-0)">
|
||||
</text><text class="terminal-3542066451-r2" x="97.6" y="44.4" textLength="158.6" clip-path="url(#terminal-3542066451-line-1)">make <recipe></text><text class="terminal-3542066451-r2" x="561.2" y="44.4" textLength="12.2" clip-path="url(#terminal-3542066451-line-1)">
|
||||
</text><text class="terminal-3542066451-r2" x="561.2" y="68.8" textLength="12.2" clip-path="url(#terminal-3542066451-line-2)">
|
||||
</text><text class="terminal-3542066451-r2" x="0" y="93.2" textLength="146.4" clip-path="url(#terminal-3542066451-line-3)">  Turn your </text><text class="terminal-3542066451-r3" x="146.4" y="93.2" textLength="122" clip-path="url(#terminal-3542066451-line-3)">`Makefile`</text><text class="terminal-3542066451-r2" x="268.4" y="93.2" textLength="61" clip-path="url(#terminal-3542066451-line-3)"> into</text><text class="terminal-3542066451-r2" x="561.2" y="93.2" textLength="12.2" clip-path="url(#terminal-3542066451-line-3)">
|
||||
</text><text class="terminal-3542066451-r2" x="0" y="117.6" textLength="73.2" clip-path="url(#terminal-3542066451-line-4)">  the </text><text class="terminal-3542066451-r4" x="73.2" y="117.6" textLength="134.2" clip-path="url(#terminal-3542066451-line-4)">task runner</text><text class="terminal-3542066451-r2" x="207.4" y="117.6" textLength="231.8" clip-path="url(#terminal-3542066451-line-4)"> you always needed.</text><text class="terminal-3542066451-r2" x="561.2" y="117.6" textLength="12.2" clip-path="url(#terminal-3542066451-line-4)">
|
||||
</text><text class="terminal-3542066451-r2" x="0" y="142" textLength="378.2" clip-path="url(#terminal-3542066451-line-5)">  See the example output below.</text><text class="terminal-3542066451-r2" x="561.2" y="142" textLength="12.2" clip-path="url(#terminal-3542066451-line-5)">
|
||||
</text><text class="terminal-3542066451-r2" x="561.2" y="166.4" textLength="12.2" clip-path="url(#terminal-3542066451-line-6)">
|
||||
</text><text class="terminal-3542066451-r5" x="24.4" y="190.8" textLength="109.8" clip-path="url(#terminal-3542066451-line-7)">bootstrap</text><text class="terminal-3542066451-r2" x="134.2" y="190.8" textLength="36.6" clip-path="url(#terminal-3542066451-line-7)"> | </text><text class="terminal-3542066451-r6" x="170.8" y="190.8" textLength="366" clip-path="url(#terminal-3542066451-line-7)">generate local dev environment</text><text class="terminal-3542066451-r2" x="561.2" y="190.8" textLength="12.2" clip-path="url(#terminal-3542066451-line-7)">
|
||||
</text><text class="terminal-3542066451-r5" x="24.4" y="215.2" textLength="109.8" clip-path="url(#terminal-3542066451-line-8)">     lint</text><text class="terminal-3542066451-r2" x="134.2" y="215.2" textLength="36.6" clip-path="url(#terminal-3542066451-line-8)"> | </text><text class="terminal-3542066451-r6" x="170.8" y="215.2" textLength="183" clip-path="url(#terminal-3542066451-line-8)">lint the python</text><text class="terminal-3542066451-r2" x="561.2" y="215.2" textLength="12.2" clip-path="url(#terminal-3542066451-line-8)">
|
||||
</text><text class="terminal-3542066451-r5" x="24.4" y="239.6" textLength="109.8" clip-path="url(#terminal-3542066451-line-9)">   assets</text><text class="terminal-3542066451-r2" x="134.2" y="239.6" textLength="36.6" clip-path="url(#terminal-3542066451-line-9)"> | </text><text class="terminal-3542066451-r6" x="170.8" y="239.6" textLength="183" clip-path="url(#terminal-3542066451-line-9)">generate assets</text><text class="terminal-3542066451-r2" x="561.2" y="239.6" textLength="12.2" clip-path="url(#terminal-3542066451-line-9)">
|
||||
</text><text class="terminal-3542066451-r5" x="24.4" y="264" textLength="109.8" clip-path="url(#terminal-3542066451-line-10)">   list-%</text><text class="terminal-3542066451-r2" x="134.2" y="264" textLength="36.6" clip-path="url(#terminal-3542066451-line-10)"> | </text><text class="terminal-3542066451-r6" x="170.8" y="264" textLength="366" clip-path="url(#terminal-3542066451-line-10)">use pathlib.Path to list files</text><text class="terminal-3542066451-r2" x="561.2" y="264" textLength="12.2" clip-path="url(#terminal-3542066451-line-10)">
|
||||
</text><text class="terminal-3542066451-r5" x="24.4" y="288.4" textLength="109.8" clip-path="url(#terminal-3542066451-line-11)">  release</text><text class="terminal-3542066451-r2" x="134.2" y="288.4" textLength="36.6" clip-path="url(#terminal-3542066451-line-11)"> | </text><text class="terminal-3542066451-r6" x="170.8" y="288.4" textLength="366" clip-path="url(#terminal-3542066451-line-11)">release new version of task.mk</text><text class="terminal-3542066451-r2" x="561.2" y="288.4" textLength="12.2" clip-path="url(#terminal-3542066451-line-11)">
|
||||
</text><text class="terminal-3542066451-r5" x="24.4" y="312.8" textLength="109.8" clip-path="url(#terminal-3542066451-line-12)"> c, clean</text><text class="terminal-3542066451-r2" x="134.2" y="312.8" textLength="36.6" clip-path="url(#terminal-3542066451-line-12)"> | </text><text class="terminal-3542066451-r6" x="170.8" y="312.8" textLength="317.2" clip-path="url(#terminal-3542066451-line-12)">remove the generated files</text><text class="terminal-3542066451-r2" x="561.2" y="312.8" textLength="12.2" clip-path="url(#terminal-3542066451-line-12)">
|
||||
</text><text class="terminal-3542066451-r5" x="24.4" y="337.2" textLength="109.8" clip-path="url(#terminal-3542066451-line-13)">     info</text><text class="terminal-3542066451-r2" x="134.2" y="337.2" textLength="36.6" clip-path="url(#terminal-3542066451-line-13)"> | </text><text class="terminal-3542066451-r6" x="170.8" y="337.2" textLength="329.4" clip-path="url(#terminal-3542066451-line-13)">demonstrate usage of tprint</text><text class="terminal-3542066451-r2" x="561.2" y="337.2" textLength="12.2" clip-path="url(#terminal-3542066451-line-13)">
|
||||
</text><text class="terminal-3542066451-r5" x="24.4" y="361.6" textLength="109.8" clip-path="url(#terminal-3542066451-line-14)">  h, help</text><text class="terminal-3542066451-r2" x="134.2" y="361.6" textLength="36.6" clip-path="url(#terminal-3542066451-line-14)"> | </text><text class="terminal-3542066451-r6" x="170.8" y="361.6" textLength="170.8" clip-path="url(#terminal-3542066451-line-14)">show this help</text><text class="terminal-3542066451-r2" x="561.2" y="361.6" textLength="12.2" clip-path="url(#terminal-3542066451-line-14)">
|
||||
</text><text class="terminal-3542066451-r2" x="561.2" y="386" textLength="12.2" clip-path="url(#terminal-3542066451-line-15)">
|
||||
</text><text class="terminal-3542066451-r2" x="0" y="410.4" textLength="561.2" clip-path="url(#terminal-3542066451-line-16)">for more info: github.com/daylinmorgan/task.mk</text><text class="terminal-3542066451-r2" x="561.2" y="410.4" textLength="12.2" clip-path="url(#terminal-3542066451-line-16)">
|
||||
</text>
|
||||
</g>
|
||||
</g>
|
||||
|
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 12 KiB |
|
@ -33,8 +33,6 @@ class Ansi:
|
|||
|
||||
def __init__(self):
|
||||
self.setcode("end", "\033[0m")
|
||||
self.setcode("default", "\033[38m")
|
||||
self.setcode("bg_default", "\033[48m")
|
||||
for name, byte in color2byte.items():
|
||||
self.setcode(name, f"\033[{fg(byte)}m")
|
||||
self.setcode(f"b_{name}", f"\033[1;{fg(byte)}m")
|
||||
|
@ -80,13 +78,6 @@ class Ansi:
|
|||
|
||||
return code + end
|
||||
|
||||
def style(self, text, style):
|
||||
if style not in self.__dict__:
|
||||
print(f"unknown style {style}")
|
||||
sys.exit(1)
|
||||
else:
|
||||
return f"{self.__dict__[style]}{text}{self.__dict__['end']}"
|
||||
|
||||
|
||||
a = ansi = Ansi()
|
||||
#% endblock %#
|
||||
|
|
|
@ -4,9 +4,8 @@ PARAMS_COLOR ?= b_magenta
|
|||
ACCENT_COLOR ?= b_yellow
|
||||
GOAL_COLOR ?= $(ACCENT_COLOR)
|
||||
MSG_COLOR ?= faint
|
||||
DIVIDER_COLOR ?= default
|
||||
DIVIDER ?= ─
|
||||
HELP_SEP ?= │
|
||||
HELP_SEP ?= |
|
||||
HELP_SORT ?= # sort goals alphabetically
|
||||
|
||||
# python f-string literals
|
||||
EPILOG ?=
|
||||
|
|
86
src/help.py
86
src/help.py
|
@ -1,100 +1,40 @@
|
|||
#% extends "py-script.mk" %#
|
||||
#% block name %#help#% endblock %#
|
||||
#% block script %#
|
||||
import argparse
|
||||
from collections import namedtuple
|
||||
import os
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
##- '$(ansi_py)' -##
|
||||
|
||||
ansi: Any
|
||||
pattern = re.compile(r"^## (.*) \| (.*)")
|
||||
|
||||
MaxLens = namedtuple("MaxLens", "goal msg")
|
||||
|
||||
# double dollar signs to prevent make escaping them
|
||||
pattern = re.compile(
|
||||
r"^## (?P<goal>.*) \| (?P<msg>.*)|^### (?P<rawmsg>.*?)?(?:\s?\| args: (?P<args>.*?))?$$"
|
||||
)
|
||||
|
||||
|
||||
def rawargs(argstring):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--align")
|
||||
parser.add_argument("-d", "--divider", action="store_true")
|
||||
parser.add_argument("-ws", "--whitespace", action="store_true")
|
||||
parser.add_argument("-ms", "--msg-style", type=str)
|
||||
return parser.parse_args(argstring.split())
|
||||
|
||||
|
||||
def gen_makefile():
|
||||
makefile = ""
|
||||
for file in os.getenv("MAKEFILE_LIST").split():
|
||||
with open(file, "r") as f:
|
||||
makefile += f.read() + "\n\n"
|
||||
return makefile
|
||||
|
||||
|
||||
def parse_make(file):
|
||||
def get_help(file):
|
||||
for line in file.splitlines():
|
||||
match = pattern.search(line)
|
||||
if match:
|
||||
if not os.getenv("SHOW_HIDDEN") and str(
|
||||
match.groupdict().get("goal")
|
||||
).startswith("_"):
|
||||
pass
|
||||
if not os.getenv("SHOW_HIDDEN") and match.groups()[0].startswith("_"):
|
||||
continue
|
||||
else:
|
||||
yield {k: v for k, v in match.groupdict().items() if v is not None}
|
||||
yield match.groups()
|
||||
|
||||
|
||||
def print_goal(goal, msg, max_goal_len):
|
||||
print(
|
||||
ansi.style(f" {goal:>{max_goal_len}}", "$(GOAL_COLOR)")
|
||||
+ " $(HELP_SEP) "
|
||||
+ ansi.style(msg, "$(MSG_COLOR)")
|
||||
)
|
||||
|
||||
|
||||
def print_rawmsg(msg, argstr, maxlens):
|
||||
args = rawargs(argstr)
|
||||
msg_style = args.msg_style if args.msg_style else "$(MSG_COLOR)"
|
||||
if msg:
|
||||
if args.align == "sep":
|
||||
print(
|
||||
f"{' '*(maxlens.goal+len('$(HELP_SEP)')+4)}{ansi.style(msg,msg_style)}"
|
||||
)
|
||||
elif args.align == "center":
|
||||
print(f" {ansi.style(msg.center(sum(maxlens)),msg_style)}")
|
||||
else:
|
||||
print(f" {ansi.style(msg,msg_style)}")
|
||||
if args.divider:
|
||||
print(
|
||||
ansi.style(
|
||||
f" {'$(DIVIDER)'*(len('$(HELP_SEP)')+sum(maxlens)+2)}",
|
||||
"$(DIVIDER_COLOR)",
|
||||
)
|
||||
)
|
||||
if args.whitespace:
|
||||
print()
|
||||
|
||||
|
||||
def print_help():
|
||||
print(f"""$(USAGE)""")
|
||||
|
||||
items = list(parse_make(gen_makefile()))
|
||||
maxlens = MaxLens(
|
||||
*(max((len(item[x]) for item in items if x in item)) for x in ["goal", "msg"])
|
||||
goals = list(get_help(makefile))
|
||||
if os.getenv("SORT_HELP", False):
|
||||
goals.sort(key=lambda i: i[0])
|
||||
goal_len = max(len(goal[0]) for goal in goals)
|
||||
|
||||
for goal, msg in goals:
|
||||
print(
|
||||
f" {ansi.$(GOAL_COLOR)}{goal:>{goal_len}}{ansi.end} $(HELP_SEP) {ansi.$(MSG_COLOR)}{msg}{ansi.end}"
|
||||
)
|
||||
|
||||
for item in items:
|
||||
if "goal" in item:
|
||||
print_goal(item["goal"], item["msg"], maxlens.goal)
|
||||
if "rawmsg" in item:
|
||||
print_rawmsg(item["rawmsg"], item.get("args", ""), maxlens)
|
||||
|
||||
print(f"""$(EPILOG)""")
|
||||
|
||||
|
||||
print_help()
|
||||
#% endblock %#
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
#% block script %#
|
||||
##- '$(ansi_py)' -##
|
||||
|
||||
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)):
|
||||
print("{:>20} {}".format(codes_names[code], code + "******" + ansi.end))
|
||||
|
||||
|
|
107
task.mk
107
task.mk
|
@ -1,7 +1,7 @@
|
|||
# }> [github.com/daylinmorgan/task.mk] <{ #
|
||||
# Copyright (c) 2022 Daylin Morgan
|
||||
# MIT License
|
||||
# version: 22.9.14
|
||||
# version: v22.9.12-dev
|
||||
#
|
||||
# task.mk should be included at the bottom of your Makefile.
|
||||
# See below for the standard configuration options that should be set prior to including this file.
|
||||
|
@ -13,9 +13,8 @@ PARAMS_COLOR ?= b_magenta
|
|||
ACCENT_COLOR ?= b_yellow
|
||||
GOAL_COLOR ?= $(ACCENT_COLOR)
|
||||
MSG_COLOR ?= faint
|
||||
DIVIDER_COLOR ?= default
|
||||
DIVIDER ?= ─
|
||||
HELP_SEP ?= │
|
||||
HELP_SEP ?= |
|
||||
HELP_SORT ?= # sort goals alphabetically
|
||||
|
||||
# python f-string literals
|
||||
EPILOG ?=
|
||||
|
@ -96,103 +95,43 @@ pysh = printf "$(call create_string,$($(1)))" | python3
|
|||
|
||||
define help_py
|
||||
|
||||
import argparse
|
||||
from collections import namedtuple
|
||||
import os
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
$(ansi_py)
|
||||
|
||||
ansi: Any
|
||||
pattern = re.compile(r"^## (.*) \| (.*)")
|
||||
|
||||
MaxLens = namedtuple("MaxLens", "goal msg")
|
||||
|
||||
# double dollar signs to prevent make escaping them
|
||||
pattern = re.compile(
|
||||
r"^## (?P<goal>.*) \| (?P<msg>.*)|^### (?P<rawmsg>.*?)?(?:\s?\| args: (?P<args>.*?))?$$"
|
||||
)
|
||||
|
||||
|
||||
def rawargs(argstring):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--align")
|
||||
parser.add_argument("-d", "--divider", action="store_true")
|
||||
parser.add_argument("-ws", "--whitespace", action="store_true")
|
||||
parser.add_argument("-ms", "--msg-style", type=str)
|
||||
return parser.parse_args(argstring.split())
|
||||
|
||||
|
||||
def gen_makefile():
|
||||
makefile = ""
|
||||
for file in os.getenv("MAKEFILE_LIST").split():
|
||||
with open(file, "r") as f:
|
||||
makefile += f.read() + "\n\n"
|
||||
return makefile
|
||||
|
||||
|
||||
def parse_make(file):
|
||||
def get_help(file):
|
||||
for line in file.splitlines():
|
||||
match = pattern.search(line)
|
||||
if match:
|
||||
if not os.getenv("SHOW_HIDDEN") and str(
|
||||
match.groupdict().get("goal")
|
||||
).startswith("_"):
|
||||
pass
|
||||
if not os.getenv("SHOW_HIDDEN") and match.groups()[0].startswith("_"):
|
||||
continue
|
||||
else:
|
||||
yield {k: v for k, v in match.groupdict().items() if v is not None}
|
||||
yield match.groups()
|
||||
|
||||
|
||||
def print_goal(goal, msg, max_goal_len):
|
||||
print(
|
||||
ansi.style(f" {goal:>{max_goal_len}}", "$(GOAL_COLOR)")
|
||||
+ " $(HELP_SEP) "
|
||||
+ ansi.style(msg, "$(MSG_COLOR)")
|
||||
)
|
||||
|
||||
|
||||
def print_rawmsg(msg, argstr, maxlens):
|
||||
args = rawargs(argstr)
|
||||
msg_style = args.msg_style if args.msg_style else "$(MSG_COLOR)"
|
||||
if msg:
|
||||
if args.align == "sep":
|
||||
print(
|
||||
f"{' '*(maxlens.goal+len('$(HELP_SEP)')+4)}{ansi.style(msg,msg_style)}"
|
||||
)
|
||||
elif args.align == "center":
|
||||
print(f" {ansi.style(msg.center(sum(maxlens)),msg_style)}")
|
||||
else:
|
||||
print(f" {ansi.style(msg,msg_style)}")
|
||||
if args.divider:
|
||||
print(
|
||||
ansi.style(
|
||||
f" {'$(DIVIDER)'*(len('$(HELP_SEP)')+sum(maxlens)+2)}",
|
||||
"$(DIVIDER_COLOR)",
|
||||
)
|
||||
)
|
||||
if args.whitespace:
|
||||
print()
|
||||
|
||||
|
||||
def print_help():
|
||||
print(f"""$(USAGE)""")
|
||||
|
||||
items = list(parse_make(gen_makefile()))
|
||||
maxlens = MaxLens(
|
||||
*(max((len(item[x]) for item in items if x in item)) for x in ["goal", "msg"])
|
||||
goals = list(get_help(makefile))
|
||||
if os.getenv("SORT_HELP", False):
|
||||
goals.sort(key=lambda i: i[0])
|
||||
goal_len = max(len(goal[0]) for goal in goals)
|
||||
|
||||
for goal, msg in goals:
|
||||
print(
|
||||
f" {ansi.$(GOAL_COLOR)}{goal:>{goal_len}}{ansi.end} $(HELP_SEP) {ansi.$(MSG_COLOR)}{msg}{ansi.end}"
|
||||
)
|
||||
|
||||
for item in items:
|
||||
if "goal" in item:
|
||||
print_goal(item["goal"], item["msg"], maxlens.goal)
|
||||
if "rawmsg" in item:
|
||||
print_rawmsg(item["rawmsg"], item.get("args", ""), maxlens)
|
||||
|
||||
print(f"""$(EPILOG)""")
|
||||
|
||||
|
||||
print_help()
|
||||
|
||||
endef
|
||||
|
||||
define ansi_py
|
||||
|
@ -229,8 +168,6 @@ class Ansi:
|
|||
|
||||
def __init__(self):
|
||||
self.setcode("end", "\033[0m")
|
||||
self.setcode("default", "\033[38m")
|
||||
self.setcode("bg_default", "\033[48m")
|
||||
for name, byte in color2byte.items():
|
||||
self.setcode(name, f"\033[{fg(byte)}m")
|
||||
self.setcode(f"b_{name}", f"\033[1;{fg(byte)}m")
|
||||
|
@ -276,13 +213,6 @@ class Ansi:
|
|||
|
||||
return code + end
|
||||
|
||||
def style(self, text, style):
|
||||
if style not in self.__dict__:
|
||||
print(f"unknown style {style}")
|
||||
sys.exit(1)
|
||||
else:
|
||||
return f"{self.__dict__[style]}{text}{self.__dict__['end']}"
|
||||
|
||||
|
||||
a = ansi = Ansi()
|
||||
|
||||
|
@ -300,7 +230,10 @@ define print_ansi_py
|
|||
|
||||
$(ansi_py)
|
||||
|
||||
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)):
|
||||
print("{:>20} {}".format(codes_names[code], code + "******" + ansi.end))
|
||||
|
||||
|
|
Loading…
Reference in a new issue