From 401eb1088b9f13caa2977fe18cefc25a4a0ea854 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Sat, 24 Sep 2022 17:34:31 -0500 Subject: [PATCH] feat: make textwrapping for deps configurable --- src/config.mk | 1 + src/help.py | 2 +- src/utils.py | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.mk b/src/config.mk index c2efd45..7485ae8 100644 --- a/src/config.mk +++ b/src/config.mk @@ -7,6 +7,7 @@ MSG_STYLE ?= faint DIVIDER ?= ─ DIVIDER_STYLE ?= default HELP_SEP ?= │ +WRAP ?= 100 # python f-string literals EPILOG ?= USAGE ?={ansi.header}usage{ansi.end}:\n make \n diff --git a/src/help.py b/src/help.py index 3a27893..ae6d405 100644 --- a/src/help.py +++ b/src/help.py @@ -13,7 +13,6 @@ from textwrap import wrap ###- # this is just to trick the LSP during development from utils import ansi, cfg - # -### @@ -92,6 +91,7 @@ def get_goal_deps(goal="task.mk"): 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=" ", ) diff --git a/src/utils.py b/src/utils.py index d7e82e2..c83637a 100644 --- a/src/utils.py +++ b/src/utils.py @@ -12,6 +12,7 @@ class Config: sep: str epilog: str usage: str + wrap: int color2byte = dict( @@ -110,5 +111,6 @@ class Ansi: a = ansi = Ansi() -cfg = Config("$(DIVIDER)", "$(HELP_SEP)", f"""$(EPILOG)""", f"""$(USAGE)""") +cfg = Config( + "$(DIVIDER)", "$(HELP_SEP)", f"""$(EPILOG)""", f"""$(USAGE)""",int('$(WRAP)')) #% endblock %#