From 234e3cee35ae0046b9b660314ef00c8621d0d415 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Thu, 22 Sep 2022 10:39:53 -0500 Subject: [PATCH] refactor: drop finicky quit-make function --- Makefile | 9 +++++---- generate.py | 2 +- src/builtins.mk | 14 +++++++++++--- src/confirm.py | 3 +-- src/help.py | 3 +-- src/quit_make.py | 12 ------------ 6 files changed, 19 insertions(+), 24 deletions(-) delete mode 100644 src/quit_make.py diff --git a/Makefile b/Makefile index 5fa2355..58f1bc9 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,10 @@ VERSION ?= $(shell git describe --tags --always --dirty | sed s'/dirty/dev/') TEMPLATES := $(shell find src/ -type f) .DEFAULT_GOAL := help +SHELL := /bin/zsh +INHERIT_SHELL = true +msg = $(if $(tprint),$(call tprint,{a.bold}==> {a.magenta}$(1){a.end}),@echo '==> $(1)') -msgfmt = {a.style('==>','bold')} {a.style('$(1)','b_magenta')} {a.style('<==','bold')} -msg = $(call tprint,$(call msgfmt ,$(1))) ### task.mk development | args: -d -ms b_green --align center ## bootstrap | generate local dev environment @@ -73,8 +74,8 @@ define USAGE endef EPILOG = \nfor more info: gh.dayl.in/task.mk -PRINT_VARS := VERSION +PRINT_VARS := VERSION SHELL -include .task.mk .task.mk: $(TEMPLATES) generate.py - $(call tprint,{a.b_yellow}re-jinjaing the local .task.mk{a.end}) + $(call msg,re-jinjaing the local .task.mk) @./generate.py $(VERSION) > .task.mk || (echo "generator failed!!" && rm .task.mk) diff --git a/generate.py b/generate.py index 619614f..a7cd4e2 100755 --- a/generate.py +++ b/generate.py @@ -4,7 +4,7 @@ import sys from pathlib import Path import jinja2 -py_script_names = ["help", "ansi", "info", "print-ansi", "vars", "confirm", "quit_make"] +py_script_names = ["help", "ansi", "info", "print-ansi", "vars", "confirm"] def get_jinja_env(): diff --git a/src/builtins.mk b/src/builtins.mk index 6e92baf..55cb4f8 100644 --- a/src/builtins.mk +++ b/src/builtins.mk @@ -4,9 +4,17 @@ ifeq (help,$(firstword $(MAKECMDGOALS))) export HELP_ARGS endif ## h, help | show this help -.PHONY: help h -help h: +ifdef HELP_ARGS +help: help-args + $(error exiting early) +.PHONY: help-args +help-args: $(call py,help_py) +else +.PHONY: help h +h help: + $(call py,help_py) +endif .PHONY: _help _help: export SHOW_HIDDEN=true _help: help @@ -32,5 +40,5 @@ _update-task.mk: curl https://raw.githubusercontent.com/daylinmorgan/task.mk/main/task.mk -o .task.mk export MAKEFILE_LIST ifndef INHERIT_SHELL -SHELL := /bin/bash +SHELL := $(shell which bash) endif diff --git a/src/confirm.py b/src/confirm.py index 0ed0875..bc78e16 100644 --- a/src/confirm.py +++ b/src/confirm.py @@ -5,7 +5,6 @@ import sys ##- '$(ansi_py)' -## -##- '$(quit_make_py)' -## def confirm(): @@ -23,5 +22,5 @@ def confirm(): if confirm(): sys.exit() else: - quit_make() + sys.exit(1) #% endblock %# diff --git a/src/help.py b/src/help.py index 77691ff..b8dc453 100644 --- a/src/help.py +++ b/src/help.py @@ -7,7 +7,6 @@ import os import re ##- '$(ansi_py)' -## -##- '$(quit_make_py)' -## MaxLens = namedtuple("MaxLens", "goal msg") @@ -157,8 +156,8 @@ def print_arg_help(help_args): def main(): help_args = os.getenv("HELP_ARGS") if help_args: - quit_make() print_arg_help(help_args) + print(a.faint) else: print_help() diff --git a/src/quit_make.py b/src/quit_make.py deleted file mode 100644 index 14cb066..0000000 --- a/src/quit_make.py +++ /dev/null @@ -1,12 +0,0 @@ -#% extends "py-script.mk" %# -#% block name %#quit_make#% endblock %# -#% block script %# - -import os, signal - - -def quit_make(): - os.kill(os.getppid(), signal.SIGQUIT) - - -#% endblock %#