diff --git a/404.html b/404.html index 7c0b546..36b8b02 100644 --- a/404.html +++ b/404.html @@ -8,8 +8,10 @@ + + - + @@ -17,11 +19,10 @@ - + - - + @@ -108,8 +109,6 @@
### 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())]) +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,$*) + $(call py,list_files_py,$*) # dollar signs will always be a problem define bash_script -echo "Is the process running bash? We can check with ps" -ps -o args= -p $$$$ | grep -E -m 1 -o '\w{0,5}sh' +echo "Is the process running bash? We can check with ps" +ps -o args= -p $$$$ | grep -E -m 1 -o '\w{0,5}sh' if [ -x "$(command -v figlet)" ]; then - echo 'no figlet :(' + echo 'no figlet :(' else - echo "What text to figlet? " - read name - figlet $$name -fi -echo "the argument below as given in the makefile itself" -echo "it's expanded before the script is passed to bash" -printf "%s\n" "$(2)" + echo "What text to figlet? " + read name + figlet $$name +fi +echo "the argument below as given in the makefile itself" +echo "it's expanded before the script is passed to bash" +printf "%s\n" "$(2)" endef ## embedded-bash | bash script with pipes and make input -.PHONY: embedded-bash +.PHONY: embedded-bash embedded-bash: - $(call tbash,bash_script,bash multiline is probably working) + $(call tbash,bash_script,bash multiline is probably working) define USAGE {a.$(HEADER_STYLE)}usage:{a.end} - make <recipe> + make <recipe> - examples of embedded scripts in `{a.magenta}Makefile{a.end}` + examples of embedded scripts in `{a.magenta}Makefile{a.end}` endef -.DEFAULT_GOAL = help +.DEFAULT_GOAL = help include $(shell git rev-parse --show-toplevel)/task.mk
## deps-only | a task/target with dependencies -.PHONY: deps-only -deps-only: foo +.PHONY: deps-only +deps-only: foo ## foo | a dummy rule that depends on the local files -.PHONY: foo -foo: $(wildcard *) - @echo 'this is a dummy rule' +.PHONY: foo +foo: $(wildcard *) + @echo 'this is a dummy rule' # bar but no docstring -.PHONY: bar +.PHONY: bar bar: - @echo 'some rule with no help string' + @echo 'some rule with no help string' define USAGE {a.header}usage:{a.end} - make <recipe> - make help <recipe> + make <recipe> + make help <recipe> endef -.DEFAULT_GOAL = help +.DEFAULT_GOAL = help include $(shell git rev-parse --show-toplevel)/task.mk
Ma You can include this as an optional dependency on your project by adding the below lines to the end of your Makefile. If someone tries to invoke make help it will download .task.mk for them. -include .task.mk -$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.28/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.28/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. -include .task.mk -$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.28/task.mk -o .task.mk) +$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.28/task.mk -o .task.mk) Alternatively, you can use the builtin rule _update-task.mk to update to the latest development version. See Usage to get started running all your tasks. @@ -599,7 +605,7 @@ See Examples for more use cases. Zsh Completions for GNU Make If you use GNU Make with zsh you may want to add the following line to your rc file to allow make to handle the autocomplete. -zstyle ':completion::complete:make:*:targets' call-command true +zstyle ':completion::complete:make:*:targets' call-command true Why Make? There are lot of GNU Make alternatives but none have near the same level of ubiquity. @@ -614,13 +620,13 @@ But like just it's a tool people don't usually already have and it' But I just want a basic help output, surely I don't need python for this... you would be right. Task.mk replaces my old make help recipe boilerplate which may better serve you (so long as you have sed/awk). ## h, help | show this help -.PHONY: help h -help h: Makefile - @awk -v fill=$(shell sed -n 's/^## \(.*\) | .*/\1/p' $< | wc -L)\ - 'match($$0,/^## (.*) \|/,name) && match($$0,/\| (.*)$$/,help)\ +.PHONY: help h +help h: Makefile + @awk -v fill=$(shell sed -n 's/^## \(.*\) | .*/\1/p' $< | wc -L)\ + 'match($$0,/^## (.*) \|/,name) && match($$0,/\| (.*)$$/,help)\ {printf "\033[1;93m%*s\033[0m | \033[30m%s\033[0m\n",\ fill,name[1],help[1];} match($$0,/^### (.*)/,str) \ - {printf "%*s \033[30m%s\033[0m\n",fill," ",str[1];}' $< + {printf "%*s \033[30m%s\033[0m\n",fill," ",str[1];}' $< @@ -653,27 +659,6 @@ But like just it's a tool people don't usually already have and it' @@ -162,7 +165,7 @@ - + daylinmorgan/task.mk @@ -207,7 +210,7 @@ - + daylinmorgan/task.mk @@ -306,9 +309,10 @@ - + + @@ -352,9 +356,10 @@ - + + @@ -395,9 +400,10 @@ - + + @@ -438,9 +444,10 @@ - + + @@ -532,10 +539,9 @@ - - - - + + + Usage @@ -547,9 +553,9 @@ Such as to document wildcard or redundant recipes. You can place these anywhere, but I recommend adding these notes directly above their relevant recipes. The format is ## <recipe> | <msg> ## build | build the project -.PHONY: build +.PHONY: build build: - ... + ... Now when you invoke make help it will parse these and generate your help output. In addition to a generic help output you can expose some configuration settings with make vars. @@ -561,11 +567,11 @@ It accepts only one argument: an unquoted f-string literal. All strings passed to tprint have access to an object ansi or a for simplicity. This stores ANSI escape codes which can be used to style your text. ## build | compile the source -.PHONY: build +.PHONY: build build: - $(call tprint,{a.cyan}Build Starting{a.end}) - ... - $(call tprint,{a.green}Build Finished{a.end}) + $(call tprint,{a.cyan}Build Starting{a.end}) + ... + $(call tprint,{a.green}Build Finished{a.end}) See this projects make info for more examples of tprint. To see the available colors and formatting(bold,italic,etc.) use the hidden recipe make _print-ansi. @@ -578,21 +584,21 @@ See this project's make info for an example. Configuration You can quickly customize some of the default behavior of task.mk by overriding the below variables prior to the -include .task.mk. # ---- [config] ---- # -HEADER_STYLE ?= b_cyan -ACCENT_STYLE ?= b_yellow -PARAMS_STYLE ?= $(ACCENT_STYLE) -GOAL_STYLE ?= $(ACCENT_STYLE) -MSG_STYLE ?= faint -DIVIDER_STYLE ?= default -DIVIDER ?= ─ -HELP_SEP ?= │ +HEADER_STYLE ?= b_cyan +ACCENT_STYLE ?= b_yellow +PARAMS_STYLE ?= $(ACCENT_STYLE) +GOAL_STYLE ?= $(ACCENT_STYLE) +MSG_STYLE ?= faint +DIVIDER_STYLE ?= default +DIVIDER ?= ─ +HELP_SEP ?= │ # python f-string literals -EPILOG ?= -USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n -INHERIT_SHELL ?= +EPILOG ?= +USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n +INHERIT_SHELL ?= To use a custom color for one of the predefined configuration variables specify only the custom method. -HEADER_STYLE = custom(fg=171,bg=227) +HEADER_STYLE = custom(fg=171,bg=227) NOTE: HELP_SEP does not change the argument definitions syntax only the format of make help. Advanced Usage: Embedded Python Scripts @@ -603,25 +609,25 @@ may be easier than balancing sub-shells and strung together awk commands. $(1) is the variable name and $(2) in this case is the implicit pattern from the rule. Pay attention to quotes. If you need to debug your python script, use DEBUG=1 when you run make and it will first print the script that will be piped to python. define list_files_py -from pathlib import Path -print("files in $(2)") -print([f.name for f in (Path("$(2)").iterdir())]) +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,$*) + $(call py,list_files_py,$*) For what it's worth there is also a predefined function for bash (named tbash) as well should you need to accomplish something similar of more easily embedding your bash script rather than having to escape every line with a backslash. define bash_script figlet task.mk 2>/dev/null || echo 'no figlet :(' -echo "This is from bash" -cat /etc/hostname -printf "%s\n" "$(2)" +echo "This is from bash" +cat /etc/hostname +printf "%s\n" "$(2)" endef -.PHONY: test-bash +.PHONY: test-bash test-bash: - $(call tbash,bash_script,test bash multiline) + $(call tbash,bash_script,test bash multiline) @@ -654,42 +660,6 @@ If you need to debug your python script, use DEBUG=1 when you run <
You can include this as an optional dependency on your project by adding the below lines to the end of your Makefile. If someone tries to invoke make help it will download .task.mk for them.
Makefile
make help
.task.mk
-include .task.mk -$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.28/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.28/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.
$(MAKECMDGOALS)
-include .task.mk -$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.28/task.mk -o .task.mk) +$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.28/task.mk -o .task.mk)
Alternatively, you can use the builtin rule _update-task.mk to update to the latest development version.
_update-task.mk
See Usage to get started running all your tasks. @@ -599,7 +605,7 @@ See Examples for more use cases.
If you use GNU Make with zsh you may want to add the following line to your rc file to allow make to handle the autocomplete.
GNU Make
make
zstyle ':completion::complete:make:*:targets' call-command true +zstyle ':completion::complete:make:*:targets' call-command true Why Make? There are lot of GNU Make alternatives but none have near the same level of ubiquity. @@ -614,13 +620,13 @@ But like just it's a tool people don't usually already have and it' But I just want a basic help output, surely I don't need python for this... you would be right. Task.mk replaces my old make help recipe boilerplate which may better serve you (so long as you have sed/awk). ## h, help | show this help -.PHONY: help h -help h: Makefile - @awk -v fill=$(shell sed -n 's/^## \(.*\) | .*/\1/p' $< | wc -L)\ - 'match($$0,/^## (.*) \|/,name) && match($$0,/\| (.*)$$/,help)\ +.PHONY: help h +help h: Makefile + @awk -v fill=$(shell sed -n 's/^## \(.*\) | .*/\1/p' $< | wc -L)\ + 'match($$0,/^## (.*) \|/,name) && match($$0,/\| (.*)$$/,help)\ {printf "\033[1;93m%*s\033[0m | \033[30m%s\033[0m\n",\ fill,name[1],help[1];} match($$0,/^### (.*)/,str) \ - {printf "%*s \033[30m%s\033[0m\n",fill," ",str[1];}' $< + {printf "%*s \033[30m%s\033[0m\n",fill," ",str[1];}' $< @@ -653,27 +659,6 @@ But like just it's a tool people don't usually already have and it'
zstyle ':completion::complete:make:*:targets' call-command true
There are lot of GNU Make alternatives but none have near the same level of ubiquity. @@ -614,13 +620,13 @@ But like just it's a tool people don't usually already have and it'
just
But I just want a basic help output, surely I don't need python for this... you would be right. Task.mk replaces my old make help recipe boilerplate which may better serve you (so long as you have sed/awk).
Task.mk
sed
awk
## h, help | show this help -.PHONY: help h -help h: Makefile - @awk -v fill=$(shell sed -n 's/^## \(.*\) | .*/\1/p' $< | wc -L)\ - 'match($$0,/^## (.*) \|/,name) && match($$0,/\| (.*)$$/,help)\ +.PHONY: help h +help h: Makefile + @awk -v fill=$(shell sed -n 's/^## \(.*\) | .*/\1/p' $< | wc -L)\ + 'match($$0,/^## (.*) \|/,name) && match($$0,/\| (.*)$$/,help)\ {printf "\033[1;93m%*s\033[0m | \033[30m%s\033[0m\n",\ fill,name[1],help[1];} match($$0,/^### (.*)/,str) \ - {printf "%*s \033[30m%s\033[0m\n",fill," ",str[1];}' $< + {printf "%*s \033[30m%s\033[0m\n",fill," ",str[1];}' $<
You can place these anywhere, but I recommend adding these notes directly above their relevant recipes. The format is ## <recipe> | <msg>
## <recipe> | <msg>
## build | build the project -.PHONY: build +.PHONY: build build: - ... + ...
Now when you invoke make help it will parse these and generate your help output.
In addition to a generic help output you can expose some configuration settings with make vars. @@ -561,11 +567,11 @@ It accepts only one argument: an unquoted f-string literal. All strings passed to tprint have access to an object ansi or a for simplicity. This stores ANSI escape codes which can be used to style your text.
make vars
tprint
ansi
a
## build | compile the source -.PHONY: build +.PHONY: build build: - $(call tprint,{a.cyan}Build Starting{a.end}) - ... - $(call tprint,{a.green}Build Finished{a.end}) + $(call tprint,{a.cyan}Build Starting{a.end}) + ... + $(call tprint,{a.green}Build Finished{a.end})
make info
To see the available colors and formatting(bold,italic,etc.) use the hidden recipe make _print-ansi.
make _print-ansi
You can quickly customize some of the default behavior of task.mk by overriding the below variables prior to the -include .task.mk.
task.mk
-include .task.mk
# ---- [config] ---- # -HEADER_STYLE ?= b_cyan -ACCENT_STYLE ?= b_yellow -PARAMS_STYLE ?= $(ACCENT_STYLE) -GOAL_STYLE ?= $(ACCENT_STYLE) -MSG_STYLE ?= faint -DIVIDER_STYLE ?= default -DIVIDER ?= ─ -HELP_SEP ?= │ +HEADER_STYLE ?= b_cyan +ACCENT_STYLE ?= b_yellow +PARAMS_STYLE ?= $(ACCENT_STYLE) +GOAL_STYLE ?= $(ACCENT_STYLE) +MSG_STYLE ?= faint +DIVIDER_STYLE ?= default +DIVIDER ?= ─ +HELP_SEP ?= │ # python f-string literals -EPILOG ?= -USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n -INHERIT_SHELL ?= +EPILOG ?= +USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n +INHERIT_SHELL ?=
To use a custom color for one of the predefined configuration variables specify only the custom method.
HEADER_STYLE = custom(fg=171,bg=227) +HEADER_STYLE = custom(fg=171,bg=227) NOTE: HELP_SEP does not change the argument definitions syntax only the format of make help. Advanced Usage: Embedded Python Scripts @@ -603,25 +609,25 @@ may be easier than balancing sub-shells and strung together awk commands. $(1) is the variable name and $(2) in this case is the implicit pattern from the rule. Pay attention to quotes. If you need to debug your python script, use DEBUG=1 when you run make and it will first print the script that will be piped to python. define list_files_py -from pathlib import Path -print("files in $(2)") -print([f.name for f in (Path("$(2)").iterdir())]) +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,$*) + $(call py,list_files_py,$*) For what it's worth there is also a predefined function for bash (named tbash) as well should you need to accomplish something similar of more easily embedding your bash script rather than having to escape every line with a backslash. define bash_script figlet task.mk 2>/dev/null || echo 'no figlet :(' -echo "This is from bash" -cat /etc/hostname -printf "%s\n" "$(2)" +echo "This is from bash" +cat /etc/hostname +printf "%s\n" "$(2)" endef -.PHONY: test-bash +.PHONY: test-bash test-bash: - $(call tbash,bash_script,test bash multiline) + $(call tbash,bash_script,test bash multiline) @@ -654,42 +660,6 @@ If you need to debug your python script, use DEBUG=1 when you run <
HEADER_STYLE = custom(fg=171,bg=227)
NOTE: HELP_SEP does not change the argument definitions syntax only the format of make help.
HELP_SEP
$(1)
$(2)
DEBUG=1
python
define list_files_py -from pathlib import Path -print("files in $(2)") -print([f.name for f in (Path("$(2)").iterdir())]) +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,$*) + $(call py,list_files_py,$*)
For what it's worth there is also a predefined function for bash (named tbash) as well should you need to accomplish something similar of more easily embedding your bash script rather than having to escape every line with a backslash.
bash
tbash
define bash_script figlet task.mk 2>/dev/null || echo 'no figlet :(' -echo "This is from bash" -cat /etc/hostname -printf "%s\n" "$(2)" +echo "This is from bash" +cat /etc/hostname +printf "%s\n" "$(2)" endef -.PHONY: test-bash +.PHONY: test-bash test-bash: - $(call tbash,bash_script,test bash multiline) + $(call tbash,bash_script,test bash multiline)