From 4ebf32a028627201e4ebfd0631c0091138e244d2 Mon Sep 17 00:00:00 2001 From: Raine Revere Date: Thu, 16 Jun 2022 12:26:00 -0600 Subject: [PATCH] Add extended help to --format option. --- README.md | 9 ++++----- src/cli-options.ts | 32 ++++++++++++++++++++++---------- src/types/RunOptions.ts | 2 +- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 0c878f9b..d4b9ca10 100644 --- a/README.md +++ b/README.md @@ -164,11 +164,10 @@ ncu "/^(?!react-).*$/" # windows --filterVersion Filter on package version using comma-or-space-delimited list, /regex/, or predicate function. ---format Enable additional output data, string or - comma-delimited list. ownerChanged: shows if the - package owner changed between versions. repo: - infers and displays links to source code - repository. (default: []) +--format Modify the output formatting or show additional + information. Specify one or more comma-delimited + values: repo, ownerChanged. Run "ncu --help + --format" for details. (default: []) -g, --global Check global packages instead of in the current project. -i, --interactive Enable interactive prompts for each dependency; diff --git a/src/cli-options.ts b/src/cli-options.ts index e38c27d9..0ef4e462 100755 --- a/src/cli-options.ts +++ b/src/cli-options.ts @@ -17,14 +17,8 @@ export interface CLIOption { type: string } -/** - * "newest" means most recently released in terms of release date, even if there are other version numbers that are higher. It includes prereleases. - * "greatest" means the highest version number, regardless of release date. It includes prereleases. - * "latest" is whatever the project's "latest" git tag points to. It's usually the non-prerelease version with the highest version number, but is ultimately decided by each project's maintainers. - * "minor" means the highest minor version without incrementing the current major. - * "patch" means the highest patch version without incrementing the current major or minor. - **/ -const getHelpTargetTable = (): string => { +/** Extended help for the --target option. */ +const extendedHelpTarget = (): string => { /* eslint-disable fp/no-mutating-methods */ const table = new Table({ @@ -68,6 +62,23 @@ You can also specify a custom function in your .ncurc.js file, or when importing ` } +/** Extended help for the --format option. */ +const extendedHelpFormat = (): string => { + /* eslint-disable fp/no-mutating-methods */ + + const table = new Table({ + colAligns: ['right', 'left'], + }) + + table.push(['repo', `Infers and displays links to the package's source code repository.`]) + table.push(['ownerChanged', `Shows if the package owner has changed.`]) + + return `Modify the output formatting or show additional information. Specify one or more comma-delimited values. + +${table.toString()} +` +} + // store CLI options separately from bin file so that they can be used to build type definitions const cliOptions: CLIOption[] = [ { @@ -170,11 +181,12 @@ const cliOptions: CLIOption[] = [ long: 'format', arg: 'value', description: - 'Enable additional output data, string or comma-delimited list. ownerChanged: shows if the package owner changed between versions. repo: infers and displays links to source code repository.', + 'Modify the output formatting or show additional information. Specify one or more comma-delimited values: repo, ownerChanged. Run "ncu --help --format" for details.', parse: value => (typeof value === 'string' ? value.split(',') : value), default: [], type: 'string[]', choices: ['ownerChanged', 'repo'], + help: extendedHelpFormat(), }, { long: 'global', @@ -353,7 +365,7 @@ As a comparison: without using the --peer option, ncu will suggest the latest ve arg: 'value', description: 'Determines the version to upgrade to: latest, newest, greatest, minor, patch, @[tag], or [function]. Run "ncu --help --target" for details. (default: "latest")', - help: getHelpTargetTable(), + help: extendedHelpTarget(), // eslint-disable-next-line no-template-curly-in-string type: `'latest' | 'newest' | 'greatest' | 'minor' | 'patch' | ${'`@${string}`'} | TargetFunction`, }, diff --git a/src/types/RunOptions.ts b/src/types/RunOptions.ts index 6d15a452..64adce53 100644 --- a/src/types/RunOptions.ts +++ b/src/types/RunOptions.ts @@ -51,7 +51,7 @@ export interface RunOptions { /** Filter on package version using comma-or-space-delimited list, /regex/, or predicate function. */ filterVersion?: string | string[] | RegExp | RegExp[] | FilterFunction - /** Enable additional output data, string or comma-delimited list. ownerChanged: shows if the package owner changed between versions. repo: infers and displays links to source code repository. */ + /** Modify the output formatting or show additional information. Specify one or more comma-delimited values: repo, ownerChanged. Run "ncu --help --format" for details. */ format?: string[] /** Check global packages instead of in the current project. */