From 949c35e2a3d09a7f2c5c8209d38463e5f2fd2158 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Thu, 19 Jan 2023 12:54:57 -0600 Subject: [PATCH] feat: add additional parameter syntax --- Makefile | 5 +++-- src/help.py | 25 ++++++++++++++++++++++++- task.mk | 25 +++++++++++++++++++++---- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index d485cbc..d149047 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,8 @@ TEMPLATES := $(shell find src/ -type f) msg = $(if $(tprint),$(call tprint,{a.bold}==> {a.magenta}$(1){a.end}),@echo '==> $(1)') -### task.mk development | args: -d -ms b_green --align center -## bootstrap | generate local dev environment +### task.mk development |> -d -ms b_green --align center +## bootstrap | generate local dev environment |> -ms b_magenta -gs b_cyan .PHONY: bootstrap env hooks bootstrap: env hooks env: @@ -17,6 +17,7 @@ hooks: @git config core.hooksPath .githooks docs-env: @mamba run -p ./env pip install mkdocs-material mkdocs-git-revision-date-localized-plugin + ## l, lint | lint the python .PHONY: l lint l lint: diff --git a/src/help.py b/src/help.py index 34e22a7..eeae323 100644 --- a/src/help.py +++ b/src/help.py @@ -20,8 +20,31 @@ a = ansi = Ansi(target="stdout") MaxLens = namedtuple("MaxLens", "goal msg") ###- double dollar signs to prevent make escaping them -### +###- re.X requires all important whitespace is escaped -### pattern = re.compile( - r"^## (?P.*?) \| (?P.*?)(?:\s?\| args: (?P.*?))?$$|^### (?P.*?)?(?:\s?\| args: (?P.*?))?$$" + r""" + ^\#\#\ + (?P.*?)\s?\|\s?(?P.*?) + \s? + (?: + (?:\|\s?args:\s?|\|>) + \s? + (?P.*?) + )? + $$ + | + ^\#\#\#\ + (?P.*?) + \s? + (?: + (?:\|\s?args:|\|\>) + \s? + (?P.*?) + )? + $$ + """ + ,re.X + ) goal_pattern = re.compile(r"""^(?!#|\t)(.*):.*\n\t""", re.MULTILINE) diff --git a/task.mk b/task.mk index f077f19..23f6e9f 100644 --- a/task.mk +++ b/task.mk @@ -1,7 +1,7 @@ # }> [github.com/daylinmorgan/task.mk] <{ # # Copyright (c) 2022 Daylin Morgan # MIT License -# version: v22.9.28-5-g83fe41d-dev +# version: v22.9.28-7-gfa977c4-dev # # 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. @@ -91,10 +91,27 @@ $(utils_py) a = ansi = Ansi(target="stdout") MaxLens = namedtuple("MaxLens", "goal msg") pattern = re.compile( - r""" - ^\#\#\ (?P.*?)\ \|\ (?P.*?)(?:\s?\|\ args:\ (?P.*?))?$$ + r""" + ^\#\#\ + (?P.*?)\s?\|\s?(?P.*?) + \s? + (?: + (?:\|\s?args:\s?|\|>) + \s? + (?P.*?) + )? + $$ | - ^\#\#\#\ (?P.*?)?(?:\s?\|\ args:\ (?P.*?))?$$""" + ^\#\#\#\ + (?P.*?) + \s? + (?: + (?:\|\s?args:|\|\>) + \s? + (?P.*?) + )? + $$ + """ ,re.X ) goal_pattern = re.compile(r"""^(?!#|\t)(.*):.*\n\t""", re.MULTILINE)