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

Wrapping the second and following line in a multiline description doesn't work if the line starts from space #1822

Closed
bk201- opened this issue Nov 18, 2022 · 6 comments
Labels
docs README (or other docs) could be improved

Comments

@bk201-
Copy link

bk201- commented Nov 18, 2022

I wanted to add an indent to the second line in the description.

program
  .option('--config <path>', 'Configuration file path')
  .option(
    '-M, --message-pattern <RegExp>',
    `Message pattern to configure where JIRA ticket number will be inserted
    * Symbols '$J' 
    * Symbols '$M' `,
  );

I've expected something like this

Usage: index [options]   
                                       
Options:                          
  --config <path>                 Configuration file path
  -M, --message-pattern <RegExp>  Message pattern to configure where JIRA ticket number will be inserted
                                     * Symbols `$J` 
                                     * Symbols `$M`
  -h, --help                      display help for command         

But got:

Usage: index [options]   
                                       
Options:                          
  --config <path>                 Configuration file path
  -M, --message-pattern <RegExp>  Message pattern to configure where JIRA ticket number will be inserted
      * Symbols '$J'
      * Symbols '$M'
  -h, --help                      display help for command  

I tried to change the template literal to a string but got the same result.

program
  .option('--config <path>', 'Configuration file path')
  .option(
    '-M, --message-pattern <RegExp>',
    'Message pattern to configure where JIRA ticket number will be inserted\n' +
    '   * Symbols `$J`\n' +
    '   * Symbols `$M`',
 // ↑ three spaces
  );

But if I remove leading spaces from the second and third line, the indent will work correctly;

Usage: index [options]

Options:
  --config <path>                 Configuration file path
  -M, --message-pattern <RegExp>  Message pattern to configure where JIRA ticket number will be inserted
                                  * Symbols `$J`
                                  * Symbols `$M`
  -h, --help                      display help for command
@shadowspawn
Copy link
Collaborator

Thanks for the detailed examples.

This is an intended behaviour rather than a bug. The wrapping code does not wrap text that looks pre-formatted. When you put spaces on the start of the second line, the wrapping code assumes you have pre-formatted the text.

The current wrapping behaviour was introduced in #956 and #1051, and the issue they took into account with pre-formatted text was #396.

@bk201-
Copy link
Author

bk201- commented Nov 18, 2022

Thank you for the clarification. I read #396, but couldn't figure out what it talking about.

In any case, it would be so great if you could add more details to the documentation.

@shadowspawn shadowspawn added the docs README (or other docs) could be improved label Nov 21, 2022
@shadowspawn
Copy link
Collaborator

Adding mention of wrapping and "pre-formatted" descriptions to README in #1859.

@shadowspawn shadowspawn added the pending release Merged into a branch for a future release, but not released yet label Apr 7, 2023
@shadowspawn
Copy link
Collaborator

Added documentation in 10.0.1

Thanks @bk201

@shadowspawn shadowspawn removed the pending release Merged into a branch for a future release, but not released yet label Apr 15, 2023
@bk201
Copy link

bk201 commented Apr 17, 2023

Hi @shadowspawn, probably a wrong mention.

@shadowspawn
Copy link
Collaborator

Oops sorry @bk201

Add one more character: thanks @bk201- for question.

@aweebit aweebit mentioned this issue Jul 10, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs README (or other docs) could be improved
Projects
None yet
Development

No branches or pull requests

3 participants