Skip to content

Commit 3b42a2a

Browse files
committed
Automatically mention extended help text in description if it exists.
1 parent 19e27cb commit 3b42a2a

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ ncu "/^(?!react-).*$/" # windows
146146
"prod,dev,bundle,optional")
147147
--deprecated Include deprecated packages.
148148
--doctor Iteratively installs upgrades and runs tests to
149-
identify breaking upgrades. Run "ncu --doctor"
150-
for detailed help. Add "-u" to execute.
149+
identify breaking upgrades. Requires "-u" to
150+
execute. Run "ncu --help --doctor" for details.
151151
--doctorInstall <command> Specifies the install script to use in doctor
152152
mode. (default: npm install/yarn)
153153
--doctorTest <command> Specifies the test script to use in doctor mode.
@@ -198,7 +198,8 @@ ncu "/^(?!react-).*$/" # windows
198198
--pre <n> Include -alpha, -beta, -rc. (default: 0; default
199199
with --newest and --greatest: 1)
200200
--prefix <path> Current working directory of npm.
201-
-r, --registry <uri> Third-party npm registry.
201+
-r, --registry <uri> Third-party npm registry. Run "ncu --help
202+
--registry" for details.
202203
-x, --reject <matches> Exclude packages matching the given string,
203204
wildcard, glob, comma-or-space-delimited list,
204205
/regex/, or predicate function. (default: [])
@@ -213,8 +214,8 @@ ncu "/^(?!react-).*$/" # windows
213214
--stdin Read package.json from stdin.
214215
-t, --target <value> Determines the version to upgrade to: latest,
215216
newest, greatest, minor, patch, @[tag], or
216-
[function]. Run "ncu --help --target" for
217-
details. (default: "latest")
217+
[function]. (default: latest). Run "ncu --help
218+
--target" for details.
218219
--timeout <ms> Global timeout in milliseconds. (default: no
219220
global timeout and 30 seconds per
220221
npm-registry-fetch)

src/bin/cli.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ program
5050
.usage('[options] [filter]')
5151

5252
// add cli options
53-
cliOptions.forEach(({ long, short, arg, description, default: defaultValue, parse }) =>
53+
cliOptions.forEach(({ long, short, arg, description, default: defaultValue, help, parse }) =>
5454
// handle 3rd/4th argument polymorphism
5555
program.option(
5656
`${short ? `-${short}, ` : ''}--${long}${arg ? ` <${arg}>` : ''}`,
57-
description,
57+
// point to help in description if extended help text is available
58+
`${description}${help ? ` Run "ncu --help --${long}" for details.` : ''}`,
5859
parse || defaultValue,
5960
parse ? defaultValue : undefined,
6061
),

src/cli-options.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ const cliOptions: CLIOption[] = [
260260
{
261261
long: 'doctor',
262262
description:
263-
'Iteratively installs upgrades and runs tests to identify breaking upgrades. Requires "-u" to execute. Run "ncu --help --doctor" for details.',
263+
'Iteratively installs upgrades and runs tests to identify breaking upgrades. Requires "-u" to execute.',
264264
type: 'boolean',
265265
help: extendedHelpDoctor(),
266266
},
@@ -309,7 +309,7 @@ const cliOptions: CLIOption[] = [
309309
long: 'format',
310310
arg: 'value',
311311
description:
312-
'Modify the output formatting or show additional information. Specify one or more comma-delimited values: group, ownerChanged, repo. Run "ncu --help --format" for details.',
312+
'Modify the output formatting or show additional information. Specify one or more comma-delimited values: group, ownerChanged, repo.',
313313
parse: value => (typeof value === 'string' ? value.split(',') : value),
314314
default: [],
315315
type: 'string[]',
@@ -382,14 +382,13 @@ const cliOptions: CLIOption[] = [
382382
short: 'p',
383383
arg: 'name',
384384
// manual default to allow overriding auto yarn detection
385-
description: 'npm, yarn, staticRegistry (default: npm). Run "ncu --help --packageManager" for details.',
385+
description: 'npm, yarn, staticRegistry (default: npm).',
386386
help: extendedHelpPackageManager(),
387387
type: 'string',
388388
},
389389
{
390390
long: 'peer',
391-
description:
392-
'Check peer dependencies of installed packages and filter updates to compatible versions. Run "ncu --help --peer" for details.',
391+
description: 'Check peer dependencies of installed packages and filter updates to compatible versions.',
393392
type: 'boolean',
394393
help: `Check peer dependencies of installed packages and filter updates to compatible versions.
395394
@@ -448,7 +447,7 @@ As a comparison: without using the --peer option, ncu will suggest the latest ve
448447
description: 'Third-party npm registry.',
449448
help: wrap(`Specify the registry to use when looking up package version numbers.
450449
451-
When --packageManager staticRegistry is set, --registry must specify a path to a JSON registry file. Run "ncu --help --packageManager" for details.`),
450+
When --packageManager staticRegistry is set, --registry must specify a path to a JSON registry file.`),
452451
type: 'string',
453452
},
454453
{
@@ -496,7 +495,7 @@ When --packageManager staticRegistry is set, --registry must specify a path to a
496495
short: 't',
497496
arg: 'value',
498497
description:
499-
'Determines the version to upgrade to: latest, newest, greatest, minor, patch, @[tag], or [function]. Run "ncu --help --target" for details. (default: "latest")',
498+
'Determines the version to upgrade to: latest, newest, greatest, minor, patch, @[tag], or [function]. (default: latest).',
500499
help: extendedHelpTarget(),
501500
// eslint-disable-next-line no-template-curly-in-string
502501
type: `'latest' | 'newest' | 'greatest' | 'minor' | 'patch' | ${'`@${string}`'} | TargetFunction`,

src/scripts/build-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const renderOption = (option: CLIOption<unknown>) => {
4747
: ''
4848

4949
// all options are optional
50-
return ` /** ${description}${defaults} */
50+
return ` /** ${description}${option.help ? ` Run "ncu --help --${option.long}" for details.` : ''}${defaults} */
5151
${option.long}?: ${type}
5252
`
5353
}

src/types/RunOptions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface RunOptions {
3030
/** Include deprecated packages. */
3131
deprecated?: boolean
3232

33-
/** Iteratively installs upgrades and runs tests to identify breaking upgrades. Run "ncu --doctor" for detailed help. Add "-u" to execute. */
33+
/** Iteratively installs upgrades and runs tests to identify breaking upgrades. Requires "-u" to execute. Run "ncu --help --doctor" for details. */
3434
doctor?: boolean
3535

3636
/** Specifies the install script to use in doctor mode. (default: npm install/yarn) */
@@ -96,7 +96,7 @@ export interface RunOptions {
9696
/** Current working directory of npm. */
9797
prefix?: string
9898

99-
/** Third-party npm registry. */
99+
/** Third-party npm registry. Run "ncu --help --registry" for details. */
100100
registry?: string
101101

102102
/** Exclude packages matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. */
@@ -117,7 +117,7 @@ export interface RunOptions {
117117
/** Read package.json from stdin. */
118118
stdin?: string
119119

120-
/** Determines the version to upgrade to: latest, newest, greatest, minor, patch, @[tag], or [function]. Run "ncu --help --target" for details. (default: "latest") */
120+
/** Determines the version to upgrade to: latest, newest, greatest, minor, patch, @[tag], or [function]. (default: latest). Run "ncu --help --target" for details. */
121121
target?: 'latest' | 'newest' | 'greatest' | 'minor' | 'patch' | `@${string}` | TargetFunction
122122

123123
/** Global timeout in milliseconds. (default: no global timeout and 30 seconds per npm-registry-fetch) */

0 commit comments

Comments
 (0)