mirror of
https://github.com/daylinmorgan/task.mk.git
synced 2024-12-22 10:00:43 -06:00
feat: add support for styling entire raw string
This commit is contained in:
parent
1bed53d3fd
commit
93287afb8e
3 changed files with 13 additions and 9 deletions
4
Makefile
4
Makefile
|
@ -5,7 +5,7 @@ TEMPLATES := $(shell find src/ -type f)
|
||||||
msgfmt = {a.style('==>','bold')} {a.style('$(1)','b_magenta')} {a.style('<==','bold')}
|
msgfmt = {a.style('==>','bold')} {a.style('$(1)','b_magenta')} {a.style('<==','bold')}
|
||||||
msg = $(call tprint,$(call msgfmt ,$(1)))
|
msg = $(call tprint,$(call msgfmt ,$(1)))
|
||||||
|
|
||||||
### task.mk development | args: --divider --align center
|
### task.mk development | args: -d --align center -ms d_green
|
||||||
## bootstrap | generate local dev environment
|
## bootstrap | generate local dev environment
|
||||||
.PHONY: bootstrap
|
.PHONY: bootstrap
|
||||||
bootstrap:
|
bootstrap:
|
||||||
|
@ -42,7 +42,7 @@ c clean:
|
||||||
@rm -f task.mk .task.mk
|
@rm -f task.mk .task.mk
|
||||||
|
|
||||||
### | args: --divider --whitespace
|
### | args: --divider --whitespace
|
||||||
### examples of task.mk features | args: --divider --align center
|
### examples of task.mk features | args: --divider --align center --msg-style d_red
|
||||||
define list_files_py
|
define list_files_py
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
print("files in $(2)")
|
print("files in $(2)")
|
||||||
|
|
|
@ -24,6 +24,7 @@ def rawargs(argstring):
|
||||||
parser.add_argument("--align")
|
parser.add_argument("--align")
|
||||||
parser.add_argument("-d", "--divider", action="store_true")
|
parser.add_argument("-d", "--divider", action="store_true")
|
||||||
parser.add_argument("-ws", "--whitespace", action="store_true")
|
parser.add_argument("-ws", "--whitespace", action="store_true")
|
||||||
|
parser.add_argument("-ms", "--msg-style", type=str)
|
||||||
return parser.parse_args(argstring.split())
|
return parser.parse_args(argstring.split())
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,15 +58,16 @@ def print_goal(goal, msg, max_goal_len):
|
||||||
|
|
||||||
def print_rawmsg(msg, argstr, maxlens):
|
def print_rawmsg(msg, argstr, maxlens):
|
||||||
args = rawargs(argstr)
|
args = rawargs(argstr)
|
||||||
|
msg_style = args.msg_style if args.msg_style else "$(MSG_COLOR)"
|
||||||
if msg:
|
if msg:
|
||||||
if args.align == "sep":
|
if args.align == "sep":
|
||||||
print(
|
print(
|
||||||
f"{' '*(maxlens.goal+len('$(HELP_SEP)')+4)}{ansi.style(msg,'$(MSG_COLOR)')}"
|
f"{' '*(maxlens.goal+len('$(HELP_SEP)')+4)}{ansi.style(msg,msg_style)}"
|
||||||
)
|
)
|
||||||
elif args.align == "center":
|
elif args.align == "center":
|
||||||
print(f" {ansi.style(msg.center(sum(maxlens)),'$(MSG_COLOR)')}")
|
print(f" {ansi.style(msg.center(sum(maxlens)),msg_style)}")
|
||||||
else:
|
else:
|
||||||
print(f" {ansi.style(msg,'$(MSG_COLOR)')}")
|
print(f" {ansi.style(msg,msg_style)}")
|
||||||
if args.divider:
|
if args.divider:
|
||||||
print(
|
print(
|
||||||
ansi.style(
|
ansi.style(
|
||||||
|
|
10
task.mk
10
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.12-8-gea398af-dev
|
# version: v22.9.12-9-g1bed53d-dev
|
||||||
#
|
#
|
||||||
# task.mk should be included at the bottom of your Makefile.
|
# task.mk should be included at the bottom of your Makefile.
|
||||||
# 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.
|
||||||
|
@ -119,6 +119,7 @@ def rawargs(argstring):
|
||||||
parser.add_argument("--align")
|
parser.add_argument("--align")
|
||||||
parser.add_argument("-d", "--divider", action="store_true")
|
parser.add_argument("-d", "--divider", action="store_true")
|
||||||
parser.add_argument("-ws", "--whitespace", action="store_true")
|
parser.add_argument("-ws", "--whitespace", action="store_true")
|
||||||
|
parser.add_argument("-ms", "--msg-style", type=str)
|
||||||
return parser.parse_args(argstring.split())
|
return parser.parse_args(argstring.split())
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,15 +153,16 @@ def print_goal(goal, msg, max_goal_len):
|
||||||
|
|
||||||
def print_rawmsg(msg, argstr, maxlens):
|
def print_rawmsg(msg, argstr, maxlens):
|
||||||
args = rawargs(argstr)
|
args = rawargs(argstr)
|
||||||
|
msg_style = args.msg_style if args.msg_style else "$(MSG_COLOR)"
|
||||||
if msg:
|
if msg:
|
||||||
if args.align == "sep":
|
if args.align == "sep":
|
||||||
print(
|
print(
|
||||||
f"{' '*(maxlens.goal+len('$(HELP_SEP)')+4)}{ansi.style(msg,'$(MSG_COLOR)')}"
|
f"{' '*(maxlens.goal+len('$(HELP_SEP)')+4)}{ansi.style(msg,msg_style)}"
|
||||||
)
|
)
|
||||||
elif args.align == "center":
|
elif args.align == "center":
|
||||||
print(f" {ansi.style(msg.center(sum(maxlens)),'$(MSG_COLOR)')}")
|
print(f" {ansi.style(msg.center(sum(maxlens)),msg_style)}")
|
||||||
else:
|
else:
|
||||||
print(f" {ansi.style(msg,'$(MSG_COLOR)')}")
|
print(f" {ansi.style(msg,msg_style)}")
|
||||||
if args.divider:
|
if args.divider:
|
||||||
print(
|
print(
|
||||||
ansi.style(
|
ansi.style(
|
||||||
|
|
Loading…
Reference in a new issue