From b5ae0445031b02b4bd003ea415f475a35807e007 Mon Sep 17 00:00:00 2001 From: Evan Purcer Date: Sat, 14 Sep 2024 12:54:10 -0700 Subject: [PATCH] make 'run --run-verbose' print all tasks _with_ task commands printed line-by-line underneath --- Makefile | 4 ++-- runfile.sh | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index fc0aa2f..67957ef 100644 --- a/Makefile +++ b/Makefile @@ -25,5 +25,5 @@ l lint: # lint all files or specific file [vars: file] .PHONY: .tasks .tasks: - @grep -E "^[a-zA-Z0-9 _-]+:[a-zA-Z0-9 _-]*#" $(MAKEFILE_LIST) \ - | sed -Ee 's/^/\t/' -e "s/[ ]*:[a-zA-Z0-9 _-]*#[ ]*/ · /" + @grep -E "^([a-zA-Z0-9 _-]+:[a-zA-Z0-9 _-]*#)" $(MAKEFILE_LIST) \ + | sed -Ee "s/^/\t/" -e "s/[ ]*:[a-zA-Z0-9 _-]*#[ ]*/ · /" diff --git a/runfile.sh b/runfile.sh index 079ca7a..92f75fa 100755 --- a/runfile.sh +++ b/runfile.sh @@ -184,6 +184,7 @@ function cd-to-nearest-file() { local lower='' upper='' title='' function main() ( set -euo pipefail local makefile='' buffer='' at='' task='' local arg='' make_args=() named_args=() pos_args=() pos_arg_idx=0 + local verbose_pattern_1='' verbose_pattern_2='' # --runfile-help, --runfile-usage · Print usage documentation then exit. # --runfile-version · Print current runfile.sh version then exit. @@ -254,6 +255,14 @@ function main() ( set -euo pipefail fi done + # If --runfile-verbose specified, use modified patterns for Makefile .tasks list, + # so that when eah task is printed, its commands are printed line-by-line underneath: + if [[ " $* " == *' --runfile-verbose '* ]] + then + verbose_pattern_1='\\s+|' + verbose_pattern_2='s/^([^[:space:]])/\\n\\1/g' + fi + # :::::::::::::::::::::::::::::::::::::::::: # Construct temporary Makefile from Runfile: cat < "${makefile}" @@ -269,8 +278,8 @@ $( .PHONY: .tasks .tasks: - @grep -E "^[a-zA-Z0-9 _-]+:[a-zA-Z0-9 _-]*#" \$(MAKEFILE_LIST) \\ - | sed -Ee 's/^/\\t/' -e "s/[ ]*:[a-zA-Z0-9 _-]*#[ ]*/ · /" + @grep -E "^(${verbose_pattern_1}[a-zA-Z0-9 _-]+:[a-zA-Z0-9 _-]*#)" \$(MAKEFILE_LIST) \\ + | sed -Ee "${verbose_pattern_2:-s/^/\\t/}" -e "s/[ ]*:[a-zA-Z0-9 _-]*#[ ]*/ · /" EOF # Done with temporary Makefile construction. # ::::::::::::::::::::::::::::::::::::::::::