ewels / rich-click

Format click help output nicely with rich.
https://ewels.github.io/rich-click/
MIT License
630 stars 36 forks source link

Rich markup support in command epilog #145

Closed carbon108 closed 12 months ago

carbon108 commented 12 months ago

Hi!

We get an issue with rich markup in command epilog

For the command:

@click.command("xyz", epilog="Example: [bold]xyz[/] --help")
def xyz():
    """Help XYZ"""
    pass

we find [bold]xyz[/] in responce

Screenshot_20231201_131127

How can one fix it? Advice is much appreciated

dwreeves commented 12 months ago

Thank you for opening this issue.

This is a bug. I am able to replicate it on my end.

The issue is in the function get_rich_epilog(), which is in rich_click/rich_click.py in 1.7 (is being moved in 1.8). It needs the text to be wrapped in _make_rich_rext().

If you want to fix, I can assign this to you (work off the branch 1.7.x if you do).

If you'd rather me fix it, absolutely no issues with that; I can release a quick fix to 1.7.x by end of day Sunday EST.

carbon108 commented 12 months ago

Hello @dwreeves Thank you for the quick and detailed reply So, please fix it if it's not an issue for you

dwreeves commented 12 months ago

@carbon108 -- rich-click==1.7.2 has been released and fixes the issue. There is also a STYLE_EPILOG_TEXT config you can use if you'd like.

Example below:

import rich_click as click

@click.command("xyz", epilog="Example: [bold]xyz[/] --help")
@click.rich_config(help_config=click.RichHelpConfiguration(use_rich_markup=True))
def xyz():
    """Help XYZ"""
    pass

xyz()
image

Note this requires USE_RICH_MARKUP to be True in order to work.

carbon108 commented 11 months ago

Thank you @dwreeves! Now it's working just fine