mirror of
https://github.com/daylinmorgan/task.mk.git
synced 2024-12-22 01:50:44 -06:00
style: improve task specific help
This commit is contained in:
parent
bf0394c5e1
commit
83fe41dbe4
3 changed files with 12 additions and 8 deletions
|
@ -5,7 +5,7 @@ ifeq (help,$(firstword $(MAKECMDGOALS)))
|
||||||
endif
|
endif
|
||||||
## h, help | show this help
|
## h, help | show this help
|
||||||
h help:
|
h help:
|
||||||
$(call py,help_py) || { echo "exiting early!"; exit 1; }
|
$(call py,help_py)
|
||||||
_help: export SHOW_HIDDEN=true
|
_help: export SHOW_HIDDEN=true
|
||||||
_help: help
|
_help: help
|
||||||
ifdef PRINT_VARS
|
ifdef PRINT_VARS
|
||||||
|
|
|
@ -185,14 +185,14 @@ def print_help():
|
||||||
def print_arg_help(help_args):
|
def print_arg_help(help_args):
|
||||||
print(f"{ansi.style('task.mk recipe help','header')}\n")
|
print(f"{ansi.style('task.mk recipe help','header')}\n")
|
||||||
for arg in help_args.split():
|
for arg in help_args.split():
|
||||||
print("\n".join(parse_goal(gen_makefile(), arg)))
|
print("\n".join((*parse_goal(gen_makefile(), arg),'\n')))
|
||||||
print()
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
help_args = os.getenv("HELP_ARGS")
|
help_args = os.getenv("HELP_ARGS")
|
||||||
if help_args:
|
if help_args:
|
||||||
print_arg_help(help_args)
|
print_arg_help(help_args)
|
||||||
|
print(f"{ansi.faint}exiting task.mk{ansi.end}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print_help()
|
print_help()
|
||||||
|
|
14
task.mk
14
task.mk
|
@ -1,7 +1,7 @@
|
||||||
# }> [github.com/daylinmorgan/task.mk] <{ #
|
# }> [github.com/daylinmorgan/task.mk] <{ #
|
||||||
# Copyright (c) 2022 Daylin Morgan
|
# Copyright (c) 2022 Daylin Morgan
|
||||||
# MIT License
|
# MIT License
|
||||||
# version: v22.9.28-3-g76e9ece-dev
|
# version: v22.9.28-4-gbf0394c-dev
|
||||||
#
|
#
|
||||||
# task.mk should be included at the bottom of your Makefile with `-include .task.mk`
|
# 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.
|
# See below for the standard configuration options that should be set prior to including this file.
|
||||||
|
@ -27,7 +27,7 @@ ifeq (help,$(firstword $(MAKECMDGOALS)))
|
||||||
endif
|
endif
|
||||||
## h, help | show this help
|
## h, help | show this help
|
||||||
h help:
|
h help:
|
||||||
$(call py,help_py) || { echo "exiting early!"; exit 1; }
|
$(call py,help_py)
|
||||||
_help: export SHOW_HIDDEN=true
|
_help: export SHOW_HIDDEN=true
|
||||||
_help: help
|
_help: help
|
||||||
ifdef PRINT_VARS
|
ifdef PRINT_VARS
|
||||||
|
@ -91,7 +91,11 @@ $(utils_py)
|
||||||
a = ansi = Ansi(target="stdout")
|
a = ansi = Ansi(target="stdout")
|
||||||
MaxLens = namedtuple("MaxLens", "goal msg")
|
MaxLens = namedtuple("MaxLens", "goal msg")
|
||||||
pattern = re.compile(
|
pattern = re.compile(
|
||||||
r"^## (?P<goal>.*?) \| (?P<msg>.*?)(?:\s?\| args: (?P<msgargs>.*?))?$$|^### (?P<rawmsg>.*?)?(?:\s?\| args: (?P<rawargs>.*?))?$$"
|
r"""
|
||||||
|
^\#\#\ (?P<goal>.*?)\ \|\ (?P<msg>.*?)(?:\s?\|\ args:\ (?P<msgargs>.*?))?$$
|
||||||
|
|
|
||||||
|
^\#\#\#\ (?P<rawmsg>.*?)?(?:\s?\|\ args:\ (?P<rawargs>.*?))?$$"""
|
||||||
|
,re.X
|
||||||
)
|
)
|
||||||
goal_pattern = re.compile(r"""^(?!#|\t)(.*):.*\n\t""", re.MULTILINE)
|
goal_pattern = re.compile(r"""^(?!#|\t)(.*):.*\n\t""", re.MULTILINE)
|
||||||
def parseargs(argstring):
|
def parseargs(argstring):
|
||||||
|
@ -229,12 +233,12 @@ def print_help():
|
||||||
def print_arg_help(help_args):
|
def print_arg_help(help_args):
|
||||||
print(f"{ansi.style('task.mk recipe help','header')}\n")
|
print(f"{ansi.style('task.mk recipe help','header')}\n")
|
||||||
for arg in help_args.split():
|
for arg in help_args.split():
|
||||||
print("\n".join(parse_goal(gen_makefile(), arg)))
|
print("\n".join((*parse_goal(gen_makefile(), arg),'\n')))
|
||||||
print()
|
|
||||||
def main():
|
def main():
|
||||||
help_args = os.getenv("HELP_ARGS")
|
help_args = os.getenv("HELP_ARGS")
|
||||||
if help_args:
|
if help_args:
|
||||||
print_arg_help(help_args)
|
print_arg_help(help_args)
|
||||||
|
print(f"{ansi.faint}exiting task.mk{ansi.end}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print_help()
|
print_help()
|
||||||
|
|
Loading…
Reference in a new issue