alecthomas / kong

Kong is a command-line parser for Go
MIT License
1.98k stars 136 forks source link

description newline stripping #376

Open lrstanley opened 10 months ago

lrstanley commented 10 months ago

Looks as though description newlines are stripped, which means printing any type of structured output inside of descriptions will break. It looks like this is due to description being added to help, and thus help being passed into the line wrapping functionality causes it to trim those things.

Some examples of things that I've seen other cli tools have in their "about/description":

I guess my question is, does this make sense to have as a supported feature? If so, should it be toggleable? E.g. kong.Description() and kong.LongDescription() or kong.FormattedDescription(), maybe (with a warning that it won't obey wrapping?)?

alecthomas commented 9 months ago

Kong's help output is fed through Go's doc formatter. I think I did that primarily to support line wrapping and integration, but I do agree that makes it difficult to control the output.

andrewbaxter commented 9 months ago

I had a comment about Help() command methods, then deleted it because I thought it might be user error, but it seems still there.

Indenting lines with a few spaces seemed to get go to avoid doing further formatting. Is go's doc formatter markdown or something?

Anyway, my use case is I wanted to add a yaml snippet in the command help text (command takes a yaml file).

The normal behavior seems fine for most things, but a way to get out of it would be helpful for that. That said, I don't think I realized it was formatting it at all, so in my own use case I don't rely on the formatting currently.