Skip to content

Commit

Permalink
src: indent long help text properly
Browse files Browse the repository at this point in the history
The previous code passed an ignored argument to StringPrototypeTrimLeft, and
tried to trim a string that didn't start with whitespace. The trim makes more
sense after the indentation has been added. Now wrapped lines actually show up
with the rest of the help text.

Before:

```
  --frozen-intrinsics                    experimental frozen intrinsics support
  --heap-prof                            Start the V8 heap profiler on start up, and write the
  heap profile to disk before exit. If --heap-prof-dir is
  not specified, write the profile to the current working
  directory.
  --heap-prof-dir=...                    Directory where the V8 heap profiles generated by
  --heap-prof will be placed.
```

After:
```
  --frozen-intrinsics                    experimental frozen intrinsics support
  --heap-prof                            Start the V8 heap profiler on start up, and write the
                                         heap profile to disk before exit. If --heap-prof-dir is
                                         not specified, write the profile to the current working
                                         directory.
  --heap-prof-dir=...                    Directory where the V8 heap profiles generated by
                                         --heap-prof will be placed.
```

Doing this made an uncharacteristic trailing newline in the `--icu-data-dir`
help text more obvious, so I removed that.
  • Loading branch information
glasser committed Mar 25, 2021
1 parent f00c243 commit a6ed940
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/internal/main/print_help.js
Expand Up @@ -152,8 +152,8 @@ function format(
else
text += StringPrototypeRepeat(' ', firstColumn - displayName.length);

text += indent(StringPrototypeTrimLeft(fold(displayHelpText, secondColumn),
firstColumn)) + '\n';
text += StringPrototypeTrimLeft(
indent(fold(displayHelpText, secondColumn), firstColumn)) + '\n';
}

if (maxFirstColumnUsed < firstColumn - 4) {
Expand Down
2 changes: 1 addition & 1 deletion src/node_options.cc
Expand Up @@ -725,7 +725,7 @@ PerProcessOptionsParser::PerProcessOptionsParser(
AddOption("--icu-data-dir",
"set ICU data load path to dir (overrides NODE_ICU_DATA)"
#ifndef NODE_HAVE_SMALL_ICU
" (note: linked-in ICU data is present)\n"
" (note: linked-in ICU data is present)"
#endif
,
&PerProcessOptions::icu_data_dir,
Expand Down

0 comments on commit a6ed940

Please sign in to comment.