mirror of
https://github.com/daylinmorgan/task.mk.git
synced 2024-11-09 19:13:14 -06:00
chore: reduce final output whitespace
This commit is contained in:
parent
7a04912891
commit
2e4a82a6f8
5 changed files with 15 additions and 38 deletions
10
generate.py
10
generate.py
|
@ -16,6 +16,8 @@ def get_jinja_env():
|
|||
block_end_string="%#",
|
||||
variable_start_string="##-",
|
||||
variable_end_string="-##",
|
||||
comment_start_string="###-",
|
||||
comment_end_string="-###",
|
||||
)
|
||||
|
||||
|
||||
|
@ -24,6 +26,10 @@ def render(env, template, **kwargs):
|
|||
return template.render(**kwargs)
|
||||
|
||||
|
||||
def dropnewlines(text):
|
||||
return "\n".join([line for line in text.splitlines() if line])
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) == 2:
|
||||
version = sys.argv[1]
|
||||
|
@ -31,9 +37,7 @@ def main():
|
|||
version = "dev"
|
||||
|
||||
env = get_jinja_env()
|
||||
|
||||
py_scripts = [render(env, f"{name}.py") for name in py_script_names]
|
||||
|
||||
py_scripts = [dropnewlines(render(env, f"{name}.py")) for name in py_script_names]
|
||||
print(render(env, "task.mk", py_scripts=py_scripts, version=version))
|
||||
|
||||
|
||||
|
|
|
@ -1,40 +1,29 @@
|
|||
# ---- [buitlin recipes] ---- #
|
||||
|
||||
## h, help | show this help
|
||||
.PHONY: help h
|
||||
help h:
|
||||
$(call py,help_py)
|
||||
|
||||
.PHONY: _help
|
||||
_help: export SHOW_HIDDEN=true
|
||||
_help: help
|
||||
|
||||
ifdef PRINT_VARS
|
||||
|
||||
$(foreach v,$(PRINT_VARS),$(eval export $(v)))
|
||||
|
||||
.PHONY: vars v
|
||||
vars v:
|
||||
$(call py,vars_py,$(PRINT_VARS))
|
||||
|
||||
endif
|
||||
|
||||
### | args: -ws --hidden
|
||||
### task.mk builtins: | args: -d --hidden
|
||||
## _print-ansi | show all possible ansi color code combinations
|
||||
.PHONY:
|
||||
_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))
|
||||
|
||||
tconfirm = $(call py,confirm_py,$(1))
|
||||
|
||||
## _update-task.mk | downloads latest development version of task.mk
|
||||
_update-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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# ---- CONFIG ---- #
|
||||
# ---- [config] ---- #
|
||||
HEADER_COLOR ?= b_cyan
|
||||
PARAMS_COLOR ?= b_magenta
|
||||
ACCENT_COLOR ?= b_yellow
|
||||
|
@ -7,11 +7,6 @@ MSG_COLOR ?= faint
|
|||
DIVIDER_COLOR ?= default
|
||||
DIVIDER ?= ─
|
||||
HELP_SEP ?= │
|
||||
|
||||
# python f-string literals
|
||||
EPILOG ?=
|
||||
define USAGE ?=
|
||||
{ansi.$(HEADER_COLOR)}usage{ansi.end}:
|
||||
make <recipe>
|
||||
|
||||
endef
|
||||
USAGE ?={ansi.$(HEADER_COLOR)}usage{ansi.end}:\n make <recipe>
|
||||
|
|
|
@ -1,21 +1,16 @@
|
|||
# ---- [python/bash script runner] ---- #
|
||||
|
||||
# modified from https://unix.stackexchange.com/a/223093
|
||||
###-- modified from https://unix.stackexchange.com/a/223093 -###
|
||||
define \n
|
||||
|
||||
|
||||
endef
|
||||
|
||||
escape_shellstring = $(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1))))
|
||||
escape_printf = $(subst \,\\,$(subst %,%%,$1))
|
||||
create_string = $(subst $(\n),\n,$(call escape_shellstring,$(call escape_printf,$1)))
|
||||
|
||||
printline = printf -- "<----------------------------------->\n"
|
||||
ifdef DEBUG
|
||||
define _debug_runner
|
||||
@printf "$(1) Script:\n"
|
||||
@printf -- "<----------------------------------->\n"
|
||||
@printf "$(call create_string,$(3))\n"
|
||||
@printf -- "<----------------------------------->\n"
|
||||
@printf "$(1) Script:\n";$(printline);printf "$(call create_string,$(3))\n";$(printline)
|
||||
@printf "$(call create_string,$(3))" | $(2)
|
||||
endef
|
||||
py = $(call _debug_runner,Python,python3,$($(1)))
|
||||
|
@ -24,5 +19,4 @@ else
|
|||
py = @python3 <(printf "$(call create_string,$($(1)))")
|
||||
tbash = @bash <(printf "$(call create_string,$($(1)))")
|
||||
endif
|
||||
|
||||
pysh = python3 <(printf "$(call create_string,$($(1)))")
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
#% include 'header.mk' %#
|
||||
|
||||
#% include 'config.mk' %#
|
||||
|
||||
#% include 'builtins.mk' %#
|
||||
|
||||
#% include 'runners.mk' %#
|
||||
|
||||
# ---- [python scripts] ---- #
|
||||
|
||||
#% for script in py_scripts %#
|
||||
#%- for script in py_scripts %#
|
||||
##- script -##
|
||||
#% endfor %#
|
||||
#%- endfor %#
|
||||
|
|
Loading…
Reference in a new issue