Skip to content

Commit

Permalink
make 'run --run-verbose' print all tasks _with_ task commands printed…
Browse files Browse the repository at this point in the history
… line-by-line underneath
  • Loading branch information
evnp committed Sep 14, 2024
1 parent 2f479c4 commit b5ae044
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 _-]*#[ ]*/ · /"
13 changes: 11 additions & 2 deletions runfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 <<EOF> "${makefile}"
Expand All @@ -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.
# ::::::::::::::::::::::::::::::::::::::::::
Expand Down

0 comments on commit b5ae044

Please sign in to comment.