mirror of
https://github.com/daylinmorgan/task.mk.git
synced 2024-12-22 10:00:43 -06:00
Compare commits
2 commits
4e57dfe0e3
...
6dad870b23
Author | SHA1 | Date | |
---|---|---|---|
6dad870b23 | |||
14b6dccbc9 |
7 changed files with 68 additions and 59 deletions
|
@ -6,7 +6,7 @@ import jinja2
|
|||
|
||||
py_script_names = [
|
||||
"help",
|
||||
"info",
|
||||
"print",
|
||||
"print-ansi",
|
||||
"vars",
|
||||
"confirm",
|
||||
|
|
|
@ -20,8 +20,8 @@ endif
|
|||
_print-ansi:
|
||||
$(call py,print_ansi_py)
|
||||
# functions to take f-string literals and pass to python print
|
||||
tprint = $(call py,info_py,$(1))
|
||||
tprint-sh = $(call pysh,info_py,$(1))
|
||||
tprint = $(call py,print_py,$(1))
|
||||
tprint-sh = $(call pysh,print_py,$(1))
|
||||
tconfirm = $(call py,confirm_py,$(1))
|
||||
## _update-task.mk | downloads latest development version of task.mk
|
||||
_update-task.mk:
|
||||
|
|
|
@ -13,6 +13,7 @@ from textwrap import wrap
|
|||
###-
|
||||
# this is just to trick the LSP during development
|
||||
from utils import ansi, cfg
|
||||
|
||||
# -###
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
#% extends "py-script.mk" %#
|
||||
#% block name %#info#% endblock %#
|
||||
#% block script %#
|
||||
##- '$(utils_py)' -##
|
||||
|
||||
print(f"""$(2)""")
|
||||
#% endblock %#
|
7
src/print.py
Normal file
7
src/print.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
#% extends "py-script.mk" %#
|
||||
#% block name %#print#% endblock %#
|
||||
#% block script %#
|
||||
##- '$(utils_py)' -##
|
||||
###- sys is imported with utils_py -###
|
||||
sys.stderr.write(f"""$(2)\n""")
|
||||
#% endblock %#
|
|
@ -65,6 +65,9 @@ class Ansi:
|
|||
"""use custom color"""
|
||||
|
||||
code, end = "\033[", "m"
|
||||
if not sys.stdout.isatty() or os.getenv("NO_COLOR", False):
|
||||
return ""
|
||||
else:
|
||||
if fg:
|
||||
if isinstance(fg, int):
|
||||
code += f"38;5;{fg}"
|
||||
|
@ -112,5 +115,6 @@ class Ansi:
|
|||
a = ansi = Ansi()
|
||||
|
||||
cfg = Config(
|
||||
"$(DIVIDER)", "$(HELP_SEP)", f"""$(EPILOG)""", f"""$(USAGE)""",int('$(WRAP)'))
|
||||
"$(DIVIDER)", "$(HELP_SEP)", f"""$(EPILOG)""", f"""$(USAGE)""", int("$(WRAP)")
|
||||
)
|
||||
#% endblock %#
|
||||
|
|
16
task.mk
16
task.mk
|
@ -1,7 +1,7 @@
|
|||
# }> [github.com/daylinmorgan/task.mk] <{ #
|
||||
# Copyright (c) 2022 Daylin Morgan
|
||||
# MIT License
|
||||
# version: 22.9.28
|
||||
# version: v22.9.28-dev
|
||||
#
|
||||
# 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.
|
||||
|
@ -42,8 +42,8 @@ endif
|
|||
_print-ansi:
|
||||
$(call py,print_ansi_py)
|
||||
# functions to take f-string literals and pass to python print
|
||||
tprint = $(call py,info_py,$(1))
|
||||
tprint-sh = $(call pysh,info_py,$(1))
|
||||
tprint = $(call py,print_py,$(1))
|
||||
tprint-sh = $(call pysh,print_py,$(1))
|
||||
tconfirm = $(call py,confirm_py,$(1))
|
||||
## _update-task.mk | downloads latest development version of task.mk
|
||||
_update-task.mk:
|
||||
|
@ -240,9 +240,9 @@ def main():
|
|||
if __name__ == "__main__":
|
||||
main()
|
||||
endef
|
||||
define info_py
|
||||
define print_py
|
||||
$(utils_py)
|
||||
print(f"""$(2)""")
|
||||
sys.stderr.write(f"""$(2)\n""")
|
||||
endef
|
||||
define print_ansi_py
|
||||
$(utils_py)
|
||||
|
@ -331,6 +331,9 @@ class Ansi:
|
|||
def custom(self, fg=None, bg=None):
|
||||
"""use custom color"""
|
||||
code, end = "\033[", "m"
|
||||
if not sys.stdout.isatty() or os.getenv("NO_COLOR", False):
|
||||
return ""
|
||||
else:
|
||||
if fg:
|
||||
if isinstance(fg, int):
|
||||
code += f"38;5;{fg}"
|
||||
|
@ -371,5 +374,6 @@ class Ansi:
|
|||
return f"{self.__dict__[style]}{text}{self.__dict__['end']}"
|
||||
a = ansi = Ansi()
|
||||
cfg = Config(
|
||||
"$(DIVIDER)", "$(HELP_SEP)", f"""$(EPILOG)""", f"""$(USAGE)""",int('$(WRAP)'))
|
||||
"$(DIVIDER)", "$(HELP_SEP)", f"""$(EPILOG)""", f"""$(USAGE)""", int("$(WRAP)")
|
||||
)
|
||||
endef
|
||||
|
|
Loading…
Reference in a new issue