cri icon indicating copy to clipboard operation
cri copied to clipboard

Allow the use of single newlines in help output

Open bmesuere opened this issue 9 years ago • 4 comments

Due to the text reflow in the help output, single newlines are ignored, double newlines are used to indicate the start of a new paragraph and paragraphs are joined with a double newline. This means it's not possible to use a line break in the description without introducing an empty line. When using lists, this results in ugly output:

This command has 3 features:

- awesome feature 1

- awesome feature 2

- awesome feature 3

We also have a lot of options.

preferred output:

This command has 3 features:
- awesome feature 1
- awesome feature 2
- awesome feature 3

We also have a lot of options.

bmesuere avatar Aug 16 '14 13:08 bmesuere

This is problematic to fix in a backwards-compatible way.

One idea I had was to parse the input as Markdown (kramdown to be precise) and convert the internal kramdown to something that is fit for terminal output.

denisdefreyne avatar Aug 16 '14 13:08 denisdefreyne

While markdown support would be great, maybe it's an option to add a metacharacter that gets translated into a newline?

bmesuere avatar Aug 16 '14 13:08 bmesuere

I just discovered tty-markdown, which might be a very good for this use case.

denisdefreyne avatar Jan 26 '18 07:01 denisdefreyne

I think just a simple {n} would be nice that StringFormatter would look for.

To make it backwards compatible, just add an option in Command that is set to false by default.

This command has 3 features:{n}
- awesome feature 1{n}
- awesome feature 2{n}
- awesome feature 3{n}

We also have a lot of options.
super_cmd = @app_cmd = Cri::Command.define(newline_metachar: true) do
  # ...
end

super_cmd.define_command(newline_metachar: true) do
  # ...
end

This is easier (just parse for {n}; don't have to include the tty-markdown gem) and backwards-compatible (newline_metachar or w/e name is set to false by default).

esotericpig avatar Mar 19 '20 10:03 esotericpig