Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newline Characters Not Rendered in CLI Command Epilog #206

Closed
cpalau opened this issue Sep 17, 2024 · 3 comments
Closed

Newline Characters Not Rendered in CLI Command Epilog #206

cpalau opened this issue Sep 17, 2024 · 3 comments
Labels
question Further information is requested

Comments

@cpalau
Copy link

cpalau commented Sep 17, 2024

Version: rich-click 1.8.3

I have a problem with newline characters (\n) in the epilog text. CLI text is not being properly rendered when output to the terminal. This results in the epilog text appearing as a single continuous line, despite attempts to format it with line breaks.

I tried """, adding \n and I have the image results. Tried in Windows, Linux and OSX with same results.

Tried different ways like:

@form4.command(
    epilog="""
        Examples:,
        python etl.py form4 process,
        python etl.py form4 process --sec-rss-feed,
        python etl.py form4 process --sec-accession-number 0001425287-24-000117,
        python etl.py form4 process --sec-accession-number 0001425287-24-000117 --download-only
    """
)

Any help ? Thanks!

image

@dwreeves
Copy link
Collaborator

Hi @cpalau.

Just posting to acknowledge I see your issue!

I'm on the busy side for the next couple days and I'll be able to look more into this either on Friday or more likely Sunday.

@dwreeves
Copy link
Collaborator

dwreeves commented Oct 2, 2024

Hello @cpalau, sorry to get back so late.

The newline behavior is deliberate; see #49 for more discussion. I believe the intent was to mimic general markdown behavior.

The way to work around it is to add double newlines, so \n\n instead of \n.

TERMINAL_WIDTH=80 python hello.py --help
                                                                                
 Usage: hello.py [OPTIONS]                                                      
                                                                                
 Simple program that greets NAME.                                               
                                                                                
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --name    TEXT  The person to greet.                                         │
│ --help          Show this message and exit.                                  │
╰──────────────────────────────────────────────────────────────────────────────╯
                                                                                
 For more information, visit our website. That's all!                           
 Have a good day                                                                

This should definitely be documented, since it isn't right now.

Newline control is a wishlist item in #179, which I am behind on to be honest. (My new job has ramped up in terms of workload, I've fallen behind on a lot of open source.)

Hopefully this solves your issue!

@dwreeves dwreeves added the question Further information is requested label Oct 2, 2024
@ewels
Copy link
Owner

ewels commented Nov 10, 2024

Closing as duplicate of #49

Note that if you use the \b escape character in the docstring then newlines will work as you expect in your example. However I just tried this in epilog and it has no effect, so you'll need double newlines there for now:

@form4.command(
    epilog="""
        Examples:

        python etl.py form4 process,

        python etl.py form4 process --sec-rss-feed,

        python etl.py form4 process --sec-accession-number 0001425287-24-000117,

        python etl.py form4 process --sec-accession-number 0001425287-24-000117 --download-only
    """
)

@ewels ewels closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants