mirror of
https://github.com/daylinmorgan/task.mk.git
synced 2024-12-22 01:50:44 -06:00
refactor: improve namespace
This commit is contained in:
parent
77e76edd16
commit
031e38a0aa
3 changed files with 27 additions and 27 deletions
|
@ -1,4 +1,4 @@
|
||||||
# ---- [buitlin recipes] ---- #
|
# ---- [builtin recipes] ---- #
|
||||||
## h, help | show this help
|
## h, help | show this help
|
||||||
.PHONY: help h
|
.PHONY: help h
|
||||||
help h:
|
help h:
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
# ---- [python/bash script runner] ---- #
|
# ---- [python/bash script runner] ---- #
|
||||||
###-- modified from https://unix.stackexchange.com/a/223093 -###
|
###-- modified from https://unix.stackexchange.com/a/223093 -###
|
||||||
define \n
|
define _newline
|
||||||
|
|
||||||
|
|
||||||
endef
|
endef
|
||||||
escape_shellstring = $(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1))))
|
_escape_shellstring = $(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1))))
|
||||||
escape_printf = $(subst \,\\,$(subst %,%%,$1))
|
_escape_printf = $(subst \,\\,$(subst %,%%,$1))
|
||||||
create_string = $(subst $(\n),\n,$(call escape_shellstring,$(call escape_printf,$1)))
|
_create_string = $(subst $(_newline),\n,$(call _escape_shellstring,$(call _escape_printf,$1)))
|
||||||
printline = printf -- "<----------------------------------->\n"
|
_printline = printf -- "<----------------------------------->\n"
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
define _debug_runner
|
define _debug_runner
|
||||||
@printf "$(1) Script:\n";$(printline);
|
@printf "$(1) Script:\n";$(_printline);
|
||||||
@printf "$(call create_string,$(3))\n" | cat -n
|
@printf "$(call _create_string,$(3))\n" | cat -n
|
||||||
@$(printline)
|
@$(_printline)
|
||||||
@printf "$(call create_string,$(3))" | $(2)
|
@printf "$(call _create_string,$(3))" | $(2)
|
||||||
endef
|
endef
|
||||||
py = $(call _debug_runner,Python,python3,$($(1)))
|
py = $(call _debug_runner,Python,python3,$($(1)))
|
||||||
tbash = $(call _debug_runner,Bash,bash,$($(1)))
|
tbash = $(call _debug_runner,Bash,bash,$($(1)))
|
||||||
else
|
else
|
||||||
py = @python3 <(printf "$(call create_string,$($(1)))")
|
py = @python3 <(printf "$(call _create_string,$($(1)))")
|
||||||
tbash = @bash <(printf "$(call create_string,$($(1)))")
|
tbash = @bash <(printf "$(call _create_string,$($(1)))")
|
||||||
endif
|
endif
|
||||||
pysh = python3 <(printf "$(call create_string,$($(1)))")
|
pysh = python3 <(printf "$(call _create_string,$($(1)))")
|
||||||
|
|
28
task.mk
28
task.mk
|
@ -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: 22.9.19
|
# version: v22.9.19-1-g584879b-dev
|
||||||
#
|
#
|
||||||
# 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.
|
||||||
|
@ -18,7 +18,7 @@ HELP_SEP ?= │
|
||||||
# python f-string literals
|
# python f-string literals
|
||||||
EPILOG ?=
|
EPILOG ?=
|
||||||
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n
|
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n
|
||||||
# ---- [buitlin recipes] ---- #
|
# ---- [builtin recipes] ---- #
|
||||||
## h, help | show this help
|
## h, help | show this help
|
||||||
.PHONY: help h
|
.PHONY: help h
|
||||||
help h:
|
help h:
|
||||||
|
@ -48,28 +48,28 @@ _update-task.mk:
|
||||||
curl https://raw.githubusercontent.com/daylinmorgan/task.mk/main/task.mk -o .task.mk
|
curl https://raw.githubusercontent.com/daylinmorgan/task.mk/main/task.mk -o .task.mk
|
||||||
export MAKEFILE_LIST
|
export MAKEFILE_LIST
|
||||||
# ---- [python/bash script runner] ---- #
|
# ---- [python/bash script runner] ---- #
|
||||||
define \n
|
define _newline
|
||||||
|
|
||||||
|
|
||||||
endef
|
endef
|
||||||
escape_shellstring = $(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1))))
|
_escape_shellstring = $(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1))))
|
||||||
escape_printf = $(subst \,\\,$(subst %,%%,$1))
|
_escape_printf = $(subst \,\\,$(subst %,%%,$1))
|
||||||
create_string = $(subst $(\n),\n,$(call escape_shellstring,$(call escape_printf,$1)))
|
_create_string = $(subst $(_newline),\n,$(call _escape_shellstring,$(call _escape_printf,$1)))
|
||||||
printline = printf -- "<----------------------------------->\n"
|
_printline = printf -- "<----------------------------------->\n"
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
define _debug_runner
|
define _debug_runner
|
||||||
@printf "$(1) Script:\n";$(printline);
|
@printf "$(1) Script:\n";$(_printline);
|
||||||
@printf "$(call create_string,$(3))\n" | cat -n
|
@printf "$(call _create_string,$(3))\n" | cat -n
|
||||||
@$(printline)
|
@$(_printline)
|
||||||
@printf "$(call create_string,$(3))" | $(2)
|
@printf "$(call _create_string,$(3))" | $(2)
|
||||||
endef
|
endef
|
||||||
py = $(call _debug_runner,Python,python3,$($(1)))
|
py = $(call _debug_runner,Python,python3,$($(1)))
|
||||||
tbash = $(call _debug_runner,Bash,bash,$($(1)))
|
tbash = $(call _debug_runner,Bash,bash,$($(1)))
|
||||||
else
|
else
|
||||||
py = @python3 <(printf "$(call create_string,$($(1)))")
|
py = @python3 <(printf "$(call _create_string,$($(1)))")
|
||||||
tbash = @bash <(printf "$(call create_string,$($(1)))")
|
tbash = @bash <(printf "$(call _create_string,$($(1)))")
|
||||||
endif
|
endif
|
||||||
pysh = python3 <(printf "$(call create_string,$($(1)))")
|
pysh = python3 <(printf "$(call _create_string,$($(1)))")
|
||||||
# ---- [python scripts] ---- #
|
# ---- [python scripts] ---- #
|
||||||
define help_py
|
define help_py
|
||||||
import argparse
|
import argparse
|
||||||
|
|
Loading…
Reference in a new issue