2022-09-05 18:37:47 -05:00
|
|
|
# }> [github.com/daylinmorgan/task.mk] <{ #
|
|
|
|
# Copyright (c) 2022 Daylin Morgan
|
|
|
|
# MIT License
|
2022-10-13 10:41:38 -05:00
|
|
|
# version: v22.9.28-dev
|
2022-09-05 18:37:47 -05:00
|
|
|
#
|
2022-09-19 02:16:24 -05:00
|
|
|
# task.mk should be included at the bottom of your Makefile with `-include .task.mk`
|
2022-09-05 18:37:47 -05:00
|
|
|
# See below for the standard configuration options that should be set prior to including this file.
|
|
|
|
# You can update your .task.mk with `make _update-task.mk`
|
2022-09-19 02:16:24 -05:00
|
|
|
# ---- [config] ---- #
|
|
|
|
HEADER_STYLE ?= b_cyan
|
|
|
|
ACCENT_STYLE ?= b_yellow
|
|
|
|
PARAMS_STYLE ?= $(ACCENT_STYLE)
|
|
|
|
GOAL_STYLE ?= $(ACCENT_STYLE)
|
|
|
|
MSG_STYLE ?= faint
|
|
|
|
DIVIDER ?= ─
|
2022-10-13 10:41:38 -05:00
|
|
|
DIVIDER_STYLE ?= default
|
2022-09-19 02:16:24 -05:00
|
|
|
HELP_SEP ?= │
|
2022-10-13 10:41:38 -05:00
|
|
|
WRAP ?= 100
|
2022-09-05 18:37:47 -05:00
|
|
|
# python f-string literals
|
|
|
|
EPILOG ?=
|
2022-10-13 10:41:38 -05:00
|
|
|
USAGE ?={ansi.header}usage{ansi.end}:\n make <recipe>\n
|
2022-09-22 11:12:58 -05:00
|
|
|
INHERIT_SHELL ?=
|
|
|
|
# ---- [builtin recipes] ---- #
|
|
|
|
ifeq (help,$(firstword $(MAKECMDGOALS)))
|
|
|
|
HELP_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
|
|
|
export HELP_ARGS
|
|
|
|
endif
|
2022-09-05 18:37:47 -05:00
|
|
|
## h, help | show this help
|
2022-10-13 10:41:38 -05:00
|
|
|
h help:
|
|
|
|
$(call py,help_py) || { echo "exiting early!"; exit 1; }
|
2022-09-05 18:37:47 -05:00
|
|
|
_help: export SHOW_HIDDEN=true
|
|
|
|
_help: help
|
|
|
|
ifdef PRINT_VARS
|
|
|
|
$(foreach v,$(PRINT_VARS),$(eval export $(v)))
|
|
|
|
.PHONY: vars v
|
|
|
|
vars v:
|
|
|
|
$(call py,vars_py,$(PRINT_VARS))
|
|
|
|
endif
|
2022-09-19 02:16:24 -05:00
|
|
|
### | args: -ws --hidden
|
|
|
|
### task.mk builtins: | args: -d --hidden
|
2022-09-05 18:37:47 -05:00
|
|
|
## _print-ansi | show all possible ansi color code combinations
|
|
|
|
_print-ansi:
|
|
|
|
$(call py,print_ansi_py)
|
|
|
|
# functions to take f-string literals and pass to python print
|
2022-10-13 10:41:38 -05:00
|
|
|
tprint = $(call py,print_py,$(1))
|
|
|
|
tprint-sh = $(call pysh,print_py,$(1))
|
2022-09-19 02:16:24 -05:00
|
|
|
tconfirm = $(call py,confirm_py,$(1))
|
|
|
|
## _update-task.mk | downloads latest development version of task.mk
|
2022-09-05 18:37:47 -05:00
|
|
|
_update-task.mk:
|
2022-09-19 02:16:24 -05:00
|
|
|
$(call tprint,{a.b_cyan}Updating task.mk{a.end})
|
2022-09-05 18:37:47 -05:00
|
|
|
curl https://raw.githubusercontent.com/daylinmorgan/task.mk/main/task.mk -o .task.mk
|
2022-10-13 10:41:38 -05:00
|
|
|
.PHONY: h help _help _print-ansi _update-task.mk
|
|
|
|
TASK_MAKEFILE_LIST := $(filter-out $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
|
|
|
export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST
|
2022-09-22 11:12:58 -05:00
|
|
|
ifndef INHERIT_SHELL
|
2022-10-13 10:41:38 -05:00
|
|
|
SHELL := $(shell which bash)
|
2022-09-22 11:12:58 -05:00
|
|
|
endif
|
2022-09-05 18:37:47 -05:00
|
|
|
# ---- [python/bash script runner] ---- #
|
2022-09-22 11:12:58 -05:00
|
|
|
define _newline
|
2022-09-05 18:37:47 -05:00
|
|
|
|
|
|
|
|
|
|
|
endef
|
2022-09-22 11:12:58 -05:00
|
|
|
_escape_shellstring = $(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1))))
|
|
|
|
_escape_printf = $(subst \,\\,$(subst %,%%,$1))
|
|
|
|
_create_string = $(subst $(_newline),\n,$(call _escape_shellstring,$(call _escape_printf,$1)))
|
|
|
|
_printline = printf -- "<----------------------------------->\n"
|
2022-09-05 18:37:47 -05:00
|
|
|
ifdef DEBUG
|
2022-09-19 02:16:24 -05:00
|
|
|
define _debug_runner
|
2022-09-22 11:12:58 -05:00
|
|
|
@printf "$(1) Script:\n";$(_printline);
|
|
|
|
@printf "$(call _create_string,$(3))\n" | cat -n
|
|
|
|
@$(_printline)
|
|
|
|
@$(2) <(printf "$(call _create_string,$(3))")
|
2022-09-05 18:37:47 -05:00
|
|
|
endef
|
2022-09-19 02:16:24 -05:00
|
|
|
py = $(call _debug_runner,Python,python3,$($(1)))
|
|
|
|
tbash = $(call _debug_runner,Bash,bash,$($(1)))
|
2022-09-05 18:37:47 -05:00
|
|
|
else
|
2022-09-22 11:12:58 -05:00
|
|
|
py = @python3 <(printf "$(call _create_string,$($(1)))")
|
|
|
|
tbash = @bash <(printf "$(call _create_string,$($(1)))")
|
2022-09-05 18:37:47 -05:00
|
|
|
endif
|
2022-09-22 11:12:58 -05:00
|
|
|
pysh = python3 <(printf "$(call _create_string,$($(1)))")
|
2022-09-05 18:37:47 -05:00
|
|
|
# ---- [python scripts] ---- #
|
|
|
|
define help_py
|
2022-09-19 02:16:24 -05:00
|
|
|
import argparse
|
|
|
|
from collections import namedtuple
|
2022-09-05 18:37:47 -05:00
|
|
|
import os
|
|
|
|
import re
|
2022-10-13 10:41:38 -05:00
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
from textwrap import wrap
|
|
|
|
$(utils_py)
|
2022-09-19 02:16:24 -05:00
|
|
|
MaxLens = namedtuple("MaxLens", "goal msg")
|
|
|
|
pattern = re.compile(
|
|
|
|
r"^## (?P<goal>.*?) \| (?P<msg>.*?)(?:\s?\| args: (?P<msgargs>.*?))?$$|^### (?P<rawmsg>.*?)?(?:\s?\| args: (?P<rawargs>.*?))?$$"
|
|
|
|
)
|
2022-09-22 11:12:58 -05:00
|
|
|
goal_pattern = re.compile(r"""^(?!#|\t)(.*):.*\n\t""", re.MULTILINE)
|
2022-09-19 02:16:24 -05:00
|
|
|
def parseargs(argstring):
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("--align")
|
|
|
|
parser.add_argument("-d", "--divider", action="store_true")
|
|
|
|
parser.add_argument("-ws", "--whitespace", action="store_true")
|
|
|
|
parser.add_argument("-ms", "--msg-style", type=str)
|
|
|
|
parser.add_argument("-gs", "--goal-style", type=str)
|
|
|
|
parser.add_argument("--hidden", action="store_true")
|
|
|
|
return parser.parse_args(argstring.split())
|
2022-10-13 10:41:38 -05:00
|
|
|
def divider(len):
|
|
|
|
return ansi.style(f" {cfg.div*len}", "div_style")
|
2022-09-19 02:16:24 -05:00
|
|
|
def gen_makefile():
|
|
|
|
makefile = ""
|
2022-10-13 10:41:38 -05:00
|
|
|
for file in os.getenv("MAKEFILE_LIST", "").split():
|
2022-09-19 02:16:24 -05:00
|
|
|
with open(file, "r") as f:
|
|
|
|
makefile += f.read() + "\n\n"
|
|
|
|
return makefile
|
2022-09-22 11:12:58 -05:00
|
|
|
def parse_help(file, hidden=False):
|
2022-09-05 18:37:47 -05:00
|
|
|
for line in file.splitlines():
|
|
|
|
match = pattern.search(line)
|
|
|
|
if match:
|
2022-09-22 11:12:58 -05:00
|
|
|
if (
|
|
|
|
not hidden
|
|
|
|
and not os.getenv("SHOW_HIDDEN")
|
|
|
|
and str(match.groupdict().get("goal")).startswith("_")
|
|
|
|
):
|
2022-09-19 02:16:24 -05:00
|
|
|
pass
|
2022-09-05 18:37:47 -05:00
|
|
|
else:
|
2022-09-19 02:16:24 -05:00
|
|
|
yield {k: v for k, v in match.groupdict().items() if v is not None}
|
2022-09-22 11:12:58 -05:00
|
|
|
def recipe_help_header(goal):
|
|
|
|
item = [
|
|
|
|
i
|
|
|
|
for i in list(parse_help(gen_makefile(), hidden=True))
|
|
|
|
if "goal" in i and goal == i["goal"]
|
|
|
|
]
|
|
|
|
if item:
|
|
|
|
return fmt_goal(
|
|
|
|
item[0]["goal"],
|
|
|
|
item[0]["msg"],
|
|
|
|
len(item[0]["goal"]),
|
|
|
|
item[0].get("msgargs", ""),
|
|
|
|
)
|
|
|
|
else:
|
2022-10-13 10:41:38 -05:00
|
|
|
return f" {ansi.style(goal,'goal')}"
|
|
|
|
def get_goal_deps(goal="task.mk"):
|
|
|
|
make = os.getenv("MAKE", "make")
|
|
|
|
cmd = [make, "-p", "-n", "-i"]
|
|
|
|
for file in os.getenv("TASK_MAKEFILE_LIST", "").split():
|
|
|
|
cmd.extend(["-f", file])
|
|
|
|
database = subprocess.check_output(cmd, universal_newlines=True)
|
|
|
|
dep_pattern = re.compile(r"^" + goal + ":(.*)?")
|
|
|
|
for line in database.splitlines():
|
|
|
|
match = dep_pattern.search(line)
|
|
|
|
if match and match.groups()[0]:
|
|
|
|
return wrap(
|
|
|
|
f"{ansi.style('deps','default')}: {ansi.style(match.groups()[0].strip(),'msg')}",
|
|
|
|
width=cfg.wrap,
|
|
|
|
initial_indent=" ",
|
|
|
|
subsequent_indent=" ",
|
|
|
|
)
|
2022-09-22 11:12:58 -05:00
|
|
|
def parse_goal(file, goal):
|
|
|
|
goals = goal_pattern.findall(file)
|
|
|
|
matched_goal = [i for i in goals if goal in i.split()]
|
|
|
|
output = []
|
|
|
|
if matched_goal:
|
|
|
|
output.append(recipe_help_header(matched_goal[0]))
|
2022-10-13 10:41:38 -05:00
|
|
|
deps = get_goal_deps(matched_goal[0])
|
|
|
|
if deps:
|
|
|
|
output.extend(deps)
|
2022-09-22 11:12:58 -05:00
|
|
|
lines = file.splitlines()
|
|
|
|
loc = [n for n, l in enumerate(lines) if l.startswith(f"{matched_goal[0]}:")][0]
|
|
|
|
recipe = []
|
|
|
|
for line in lines[loc + 1 :]:
|
|
|
|
if not line.startswith("\t"):
|
|
|
|
break
|
2022-10-13 10:41:38 -05:00
|
|
|
recipe.append(f" {line.strip()}")
|
|
|
|
output.append(divider(max((len(l.strip()) for l in recipe))))
|
|
|
|
output.append("\n".join(recipe))
|
2022-09-22 11:12:58 -05:00
|
|
|
else:
|
2022-10-13 10:41:38 -05:00
|
|
|
deps = get_goal_deps(goal)
|
|
|
|
if deps:
|
|
|
|
output.append(recipe_help_header(goal))
|
|
|
|
output.extend(deps)
|
|
|
|
if not output:
|
|
|
|
output.append(f"{ansi.style('ERROR','b_red')}: Failed to find goal: {goal}")
|
2022-09-22 11:12:58 -05:00
|
|
|
return output
|
2022-09-19 02:16:24 -05:00
|
|
|
def fmt_goal(goal, msg, max_goal_len, argstr):
|
|
|
|
args = parseargs(argstr)
|
2022-10-13 10:41:38 -05:00
|
|
|
goal_style = args.goal_style.strip() if args.goal_style else "goal"
|
|
|
|
msg_style = args.msg_style.strip() if args.msg_style else "msg"
|
2022-09-19 02:16:24 -05:00
|
|
|
return (
|
|
|
|
ansi.style(f" {goal:>{max_goal_len}}", goal_style)
|
|
|
|
+ f" $(HELP_SEP) "
|
|
|
|
+ ansi.style(msg, msg_style)
|
2022-09-05 18:37:47 -05:00
|
|
|
)
|
2022-09-19 02:16:24 -05:00
|
|
|
def fmt_rawmsg(msg, argstr, maxlens):
|
|
|
|
args = parseargs(argstr)
|
|
|
|
lines = []
|
2022-10-13 10:41:38 -05:00
|
|
|
msg_style = args.msg_style.strip() if args.msg_style else "msg"
|
2022-09-19 02:16:24 -05:00
|
|
|
if not os.getenv("SHOW_HIDDEN") and args.hidden:
|
|
|
|
return []
|
|
|
|
if msg:
|
|
|
|
if args.align == "sep":
|
|
|
|
lines.append(
|
2022-10-13 10:41:38 -05:00
|
|
|
f"{' '*(maxlens.goal+len(cfg.sep)+4)}{ansi.style(msg,msg_style)}"
|
2022-09-19 02:16:24 -05:00
|
|
|
)
|
|
|
|
elif args.align == "center":
|
|
|
|
lines.append(f" {ansi.style(msg.center(sum(maxlens)),msg_style)}")
|
|
|
|
else:
|
|
|
|
lines.append(f" {ansi.style(msg,msg_style)}")
|
|
|
|
if args.divider:
|
2022-10-13 10:41:38 -05:00
|
|
|
lines.append(divider(len(cfg.sep) + sum(maxlens) + 2))
|
2022-09-19 02:16:24 -05:00
|
|
|
if args.whitespace:
|
|
|
|
lines.append("\n")
|
|
|
|
return lines
|
|
|
|
def print_help():
|
2022-10-13 10:41:38 -05:00
|
|
|
lines = [cfg.usage]
|
2022-09-22 11:12:58 -05:00
|
|
|
items = list(parse_help(gen_makefile()))
|
2022-09-19 02:16:24 -05:00
|
|
|
maxlens = MaxLens(
|
|
|
|
*(max((len(item[x]) for item in items if x in item)) for x in ["goal", "msg"])
|
|
|
|
)
|
|
|
|
for item in items:
|
|
|
|
if "goal" in item:
|
|
|
|
lines.append(
|
|
|
|
fmt_goal(
|
|
|
|
item["goal"], item["msg"], maxlens.goal, item.get("msgargs", "")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if "rawmsg" in item:
|
|
|
|
lines.extend(fmt_rawmsg(item["rawmsg"], item.get("rawargs", ""), maxlens))
|
2022-10-13 10:41:38 -05:00
|
|
|
lines.append(cfg.epilog)
|
2022-09-19 02:16:24 -05:00
|
|
|
print("\n".join(lines))
|
2022-09-22 11:12:58 -05:00
|
|
|
def print_arg_help(help_args):
|
2022-10-13 10:41:38 -05:00
|
|
|
print(f"{ansi.style('task.mk recipe help','header')}\n")
|
2022-09-22 11:12:58 -05:00
|
|
|
for arg in help_args.split():
|
|
|
|
print("\n".join(parse_goal(gen_makefile(), arg)))
|
2022-10-13 10:41:38 -05:00
|
|
|
print()
|
2022-09-22 11:12:58 -05:00
|
|
|
def main():
|
|
|
|
help_args = os.getenv("HELP_ARGS")
|
|
|
|
if help_args:
|
|
|
|
print_arg_help(help_args)
|
2022-10-13 10:41:38 -05:00
|
|
|
sys.exit(1)
|
2022-09-22 11:12:58 -05:00
|
|
|
else:
|
|
|
|
print_help()
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
2022-09-05 18:37:47 -05:00
|
|
|
endef
|
2022-10-13 10:41:38 -05:00
|
|
|
define print_py
|
|
|
|
$(utils_py)
|
|
|
|
sys.stderr.write(f"""$(2)\n""")
|
|
|
|
endef
|
|
|
|
define print_ansi_py
|
|
|
|
$(utils_py)
|
|
|
|
sep = f"$(HELP_SEP)"
|
|
|
|
codes_names = {getattr(ansi, attr): attr for attr in ansi.__dict__}
|
|
|
|
for code in sorted(codes_names.keys(), key=lambda item: (len(item), item)):
|
|
|
|
print(f"{codes_names[code]:>20} {sep} {code+'*****'+ansi.end} {sep} {repr(code)}")
|
|
|
|
endef
|
|
|
|
define vars_py
|
|
|
|
import os
|
|
|
|
$(utils_py)
|
|
|
|
vars = "$2".split()
|
|
|
|
length = max((len(v) for v in vars))
|
|
|
|
print(f"{ansi.header}vars{ansi.end}:\n")
|
|
|
|
for v in vars:
|
|
|
|
print(f" {ansi.params}{v:<{length}}{ansi.end} = {os.getenv(v)}")
|
|
|
|
print()
|
|
|
|
endef
|
|
|
|
define confirm_py
|
|
|
|
import sys
|
|
|
|
$(utils_py)
|
|
|
|
def confirm():
|
|
|
|
"""
|
|
|
|
Ask user to enter Y or N (case-insensitive).
|
|
|
|
:return: True if the answer is Y.
|
|
|
|
:rtype: bool
|
|
|
|
"""
|
|
|
|
answer = ""
|
|
|
|
while answer not in ["y", "n"]:
|
|
|
|
answer = input(f"""$(2) {a.b_red}[Y/n]{a.end} """).lower()
|
|
|
|
return answer == "y"
|
|
|
|
if confirm():
|
|
|
|
sys.exit()
|
|
|
|
else:
|
|
|
|
sys.exit(1)
|
|
|
|
endef
|
|
|
|
define utils_py
|
2022-09-05 18:37:47 -05:00
|
|
|
import os
|
|
|
|
import sys
|
2022-10-13 10:41:38 -05:00
|
|
|
from dataclasses import dataclass
|
|
|
|
@dataclass
|
|
|
|
class Config:
|
|
|
|
div: str
|
|
|
|
sep: str
|
|
|
|
epilog: str
|
|
|
|
usage: str
|
|
|
|
wrap: int
|
2022-09-05 18:37:47 -05:00
|
|
|
color2byte = dict(
|
|
|
|
black=0,
|
|
|
|
red=1,
|
|
|
|
green=2,
|
|
|
|
yellow=3,
|
|
|
|
blue=4,
|
|
|
|
magenta=5,
|
|
|
|
cyan=6,
|
|
|
|
white=7,
|
|
|
|
)
|
|
|
|
state2byte = dict(
|
|
|
|
bold=1, faint=2, italic=3, underline=4, blink=5, fast_blink=6, crossed=9
|
|
|
|
)
|
2022-09-19 02:16:24 -05:00
|
|
|
addfg = lambda byte: byte + 30
|
|
|
|
addbg = lambda byte: byte + 40
|
2022-09-05 18:37:47 -05:00
|
|
|
class Ansi:
|
2022-09-19 02:16:24 -05:00
|
|
|
"""ANSI escape codes"""
|
2022-09-05 18:37:47 -05:00
|
|
|
def __init__(self):
|
|
|
|
self.setcode("end", "\033[0m")
|
2022-09-19 02:16:24 -05:00
|
|
|
self.setcode("default", "\033[38m")
|
|
|
|
self.setcode("bg_default", "\033[48m")
|
2022-09-05 18:37:47 -05:00
|
|
|
for name, byte in color2byte.items():
|
2022-09-19 02:16:24 -05:00
|
|
|
self.setcode(name, f"\033[{addfg(byte)}m")
|
|
|
|
self.setcode(f"b_{name}", f"\033[1;{addfg(byte)}m")
|
|
|
|
self.setcode(f"d_{name}", f"\033[2;{addfg(byte)}m")
|
2022-09-05 18:37:47 -05:00
|
|
|
for bgname, bgbyte in color2byte.items():
|
2022-09-19 02:16:24 -05:00
|
|
|
self.setcode(
|
|
|
|
f"{name}_on_{bgname}", f"\033[{addbg(bgbyte)};{addfg(byte)}m"
|
|
|
|
)
|
2022-09-05 18:37:47 -05:00
|
|
|
for name, byte in state2byte.items():
|
|
|
|
self.setcode(name, f"\033[{byte}m")
|
2022-10-13 10:41:38 -05:00
|
|
|
self.add_cfg()
|
2022-09-19 02:16:24 -05:00
|
|
|
def setcode(self, name, escape_code):
|
|
|
|
"""create attr for style and escape code"""
|
|
|
|
if not sys.stdout.isatty() or os.getenv("NO_COLOR", False):
|
|
|
|
setattr(self, name, "")
|
|
|
|
else:
|
|
|
|
setattr(self, name, escape_code)
|
|
|
|
def custom(self, fg=None, bg=None):
|
|
|
|
"""use custom color"""
|
|
|
|
code, end = "\033[", "m"
|
2022-10-13 10:41:38 -05:00
|
|
|
if not sys.stdout.isatty() or os.getenv("NO_COLOR", False):
|
|
|
|
return ""
|
|
|
|
else:
|
|
|
|
if fg:
|
|
|
|
if isinstance(fg, int):
|
|
|
|
code += f"38;5;{fg}"
|
|
|
|
elif (isinstance(fg, list) or isinstance(fg, tuple)) and len(fg) == 1:
|
|
|
|
code += f"38;5;{fg[0]}"
|
|
|
|
elif (isinstance(fg, list) or isinstance(fg, tuple)) and len(fg) == 3:
|
|
|
|
code += f"38;2;{';'.join((str(i) for i in fg))}"
|
|
|
|
else:
|
|
|
|
print("Expected one or three values for fg as a list")
|
|
|
|
sys.exit(1)
|
|
|
|
if bg:
|
|
|
|
if isinstance(bg, int):
|
|
|
|
code += f"{';' if fg else ''}48;5;{bg}"
|
|
|
|
elif (isinstance(bg, list) or isinstance(bg, tuple)) and len(bg) == 1:
|
|
|
|
code += f"{';' if fg else ''}48;5;{bg[0]}"
|
|
|
|
elif (isinstance(bg, list) or isinstance(bg, tuple)) and len(bg) == 3:
|
|
|
|
code += f"{';' if fg else ''}48;2;{';'.join((str(i) for i in bg))}"
|
|
|
|
else:
|
|
|
|
print("Expected one or three values for bg as a list")
|
|
|
|
sys.exit(1)
|
|
|
|
return code + end
|
|
|
|
def add_cfg(self):
|
|
|
|
cfg_styles = {
|
|
|
|
"header": "$(HEADER_STYLE)",
|
|
|
|
"accent": "$(ACCENT_STYLE)",
|
|
|
|
"params": "$(PARAMS_STYLE)",
|
|
|
|
"goal": "$(GOAL_STYLE)",
|
|
|
|
"msg": "$(MSG_STYLE)",
|
|
|
|
"div_style": "$(DIVIDER_STYLE)",
|
|
|
|
}
|
|
|
|
for name, style in cfg_styles.items():
|
|
|
|
self.setcode(name, getattr(self, style))
|
2022-09-19 02:16:24 -05:00
|
|
|
def style(self, text, style):
|
|
|
|
if style not in self.__dict__:
|
|
|
|
print(f"unknown style: {style}")
|
|
|
|
sys.exit(1)
|
|
|
|
else:
|
|
|
|
return f"{self.__dict__[style]}{text}{self.__dict__['end']}"
|
2022-09-05 18:37:47 -05:00
|
|
|
a = ansi = Ansi()
|
2022-10-13 10:41:38 -05:00
|
|
|
cfg = Config(
|
|
|
|
"$(DIVIDER)", "$(HELP_SEP)", f"""$(EPILOG)""", f"""$(USAGE)""", int("$(WRAP)")
|
|
|
|
)
|
2022-09-19 02:16:24 -05:00
|
|
|
endef
|