Skip to content

Commit

Permalink
add epilog text formatting support
Browse files Browse the repository at this point in the history
  • Loading branch information
dwreeves committed Dec 2, 2023
1 parent 3128c30 commit 670b466
Show file tree
Hide file tree
Showing 27 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ STYLE_METAVAR = "bold yellow"
STYLE_METAVAR_APPEND = "dim yellow"
STYLE_METAVAR_SEPARATOR = "dim"
STYLE_HEADER_TEXT = ""
STYLE_EPILOG_TEXT = ""
STYLE_FOOTER_TEXT = ""
STYLE_USAGE = "yellow"
STYLE_USAGE_COMMAND = "bold"
Expand Down
4 changes: 3 additions & 1 deletion src/rich_click/rich_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
STYLE_METAVAR_APPEND: rich.style.StyleType = "dim yellow"
STYLE_METAVAR_SEPARATOR: rich.style.StyleType = "dim"
STYLE_HEADER_TEXT: rich.style.StyleType = ""
STYLE_EPILOG_TEXT: rich.style.StyleType = ""
STYLE_FOOTER_TEXT: rich.style.StyleType = ""
STYLE_USAGE: rich.style.StyleType = "yellow"
STYLE_USAGE_COMMAND: rich.style.StyleType = "bold"
Expand Down Expand Up @@ -722,7 +723,7 @@ class MetavarHighlighter(RegexHighlighter):
# Remove single linebreaks, replace double with single
lines = obj.epilog.split("\n\n")
epilogue = "\n".join([x.replace("\n", " ").strip() for x in lines])
console.print(Padding(Align(highlighter(epilogue), pad=False), 1))
console.print(Padding(Align(_make_rich_rext(epilogue, config.style_epilog_text, formatter), pad=False), 1))

# Footer text if we have it
if config.footer_text:
Expand Down Expand Up @@ -820,6 +821,7 @@ def get_module_help_configuration() -> RichHelpConfiguration:
STYLE_METAVAR_APPEND,
STYLE_METAVAR_SEPARATOR,
STYLE_HEADER_TEXT,
STYLE_EPILOG_TEXT,
STYLE_FOOTER_TEXT,
STYLE_USAGE,
STYLE_USAGE_COMMAND,
Expand Down
1 change: 1 addition & 0 deletions src/rich_click/rich_help_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class RichHelpConfiguration:
style_metavar_append: rich.style.StyleType = field(default="dim yellow")
style_metavar_separator: rich.style.StyleType = field(default="dim")
style_header_text: rich.style.StyleType = field(default="")
style_epilog_text: rich.style.StyleType = field(default="")
style_footer_text: rich.style.StyleType = field(default="")
style_usage: rich.style.StyleType = field(default="yellow")
style_usage_command: rich.style.StyleType = field(default="bold")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"style_metavar_append": "dim yellow",
"style_metavar_separator": "dim",
"style_header_text": "",
"style_epilog_text": "",
"style_footer_text": "",
"style_usage": "yellow",
"style_usage_command": "bold",
Expand Down

0 comments on commit 670b466

Please sign in to comment.