chore: add some helpful notes about make variables

This commit is contained in:
Daylin Morgan 2023-01-20 12:23:03 -06:00
parent 365e0e1353
commit 3873df00ce
4 changed files with 13 additions and 10 deletions

View file

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

View file

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

View file

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

11
task.mk
View file

@ -1,7 +1,7 @@
# }> [github.com/daylinmorgan/task.mk] <{ # # }> [github.com/daylinmorgan/task.mk] <{ #
# Copyright (c) 2022 Daylin Morgan # Copyright (c) 2022 Daylin Morgan
# MIT License # MIT License
# version: v22.9.28-16-g920c7c2dev # version: v22.9.28-17-g365e0e1dev
# #
# task.mk should be included at the bottom of your Makefile with `-include .task.mk` # task.mk should be included at the bottom of your Makefile with `-include .task.mk`
# See below for the standard configuration options that should be set prior to including this file. # See below for the standard configuration options that should be set prior to including this file.
@ -90,17 +90,17 @@ MaxLens = namedtuple("MaxLens", "goal msg")
pattern = re.compile( pattern = re.compile(
r""" r"""
(?: (?:
^\#\#\#\s+ ^\#\#\#\s+ # <- raw message
| |
^(?: ^(?:
(?:\#\#\s+)? (?:\#\#\s+)?
(?P<goal>.*?)(?:\s+\|>|:.*?\#\#)\s+ (?P<goal>.*?)(?:\s+\|>|:.*?\#\#)\s+
) # <- a custom goal or actual recipe
) )
) (?P<msg>.*?)?\s? # <- help text (optional)
(?P<msg>.*?)?\s?
(?:\|>\s+ (?:\|>\s+
(?P<msgargs>.*?) (?P<msgargs>.*?)
)? )? # <- style args (optional)
$$ $$
""", """,
re.X, re.X,
@ -391,6 +391,7 @@ class Ansi:
print("Expected one or three values for bg as a list") print("Expected one or three values for bg as a list")
sys.exit(1) sys.exit(1)
return code + end return code + end
def add_cfg(self): def add_cfg(self):
cfg_styles = { cfg_styles = {
"header": "$(HEADER_STYLE)", "header": "$(HEADER_STYLE)",