clikt icon indicating copy to clipboard operation
clikt copied to clipboard

Advanced help message formatting?

Open kgruhler opened this issue 4 years ago • 2 comments

Is there a possiblity to format the help message with your own paragraphs and font styles like bold or italic ?

I'd like to add examples to my cli and I'm struggling to print pretty examples to the help.

For instance, this is my current help message:

...
CliktCommand(help = """
    |Remove Command.
    | 
    |This is my help message.
    | Mulitple lines """.trimMargin(),
    epilog = """
    | EXAMPLES:
    |
    | 1.) COMMAND remove
    | => Removes ALL available instances.
    | 
    | 2.) COMMAND remove -a myalias
    | => Removes only instances with ALIAS "myalias".
    """.trimMargin(), 
...

But the output looks like: (The 2.) doesn't make a new line before '=>')

EXAMPLES:

1.) COMMAND remove
 => Updates ALL available instances.

2.) COMMAND remove -a myalias => Removes only instances with ALIAS "myalias".

Isn't it possible to do something like the OPTIONS, but just for Examples or my own text ?

-o, --option            option help message with tab indentation 
-p, --port               port help message with tab indentatin and multiple
                              lines

Thanks

kgruhler avatar May 25 '20 11:05 kgruhler

The triple backticks did the trick :) Found it here in the documentation: https://ajalt.github.io/clikt/documenting/#preformatting-paragraphs Unfortunately the whitespaces don't remain.

kgruhler avatar May 25 '20 12:05 kgruhler

Unfortunately the whitespaces don't remain.

Can you give an example of what you're trying?

ajalt avatar May 25 '20 15:05 ajalt

The 4.0 uses mordant for output, which can format help how you'd like.

ajalt avatar Jun 28 '23 17:06 ajalt