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

feat: show possible values for option in help output #2819

Merged
merged 6 commits into from Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/webpack-cli/lib/webpack-cli.js
Expand Up @@ -1363,10 +1363,21 @@ class WebpackCLI {
);
}

const flag = this.getBuiltInOptions().find(
(flag) => option.long === `--${flag.name}`,
);

if (flag && flag.configs[0].values) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can have more them, i.e. config[1]/config[2], I think better use map here and collect them

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update 👍

this.logger.raw(
`${bold("Possible values:")} ${JSON.stringify(
flag.configs[0].values.join(" | "),
)}`,
);
}

this.logger.raw("");

// TODO implement this after refactor cli arguments
// logger.raw('Possible values: foo | bar');
// logger.raw('Documentation: https://webpack.js.org/option/name/');
} else {
outputIncorrectUsageOfHelp();
Expand Down
Expand Up @@ -2560,6 +2560,7 @@ exports[`help should show help information using the "help --mode" option: stder
exports[`help should show help information using the "help --mode" option: stdout 1`] = `
"Usage: webpack --mode <value>
Description: Defines the mode to pass to webpack.
Possible values: \\"development | production | none\\"

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand All @@ -2571,6 +2572,7 @@ Made with ♥ by the webpack team."
exports[`help should show help information using the "help --mode" option: stdout 2`] = `
"Usage: webpack --mode <value>
Description: Defines the mode to pass to webpack.
Possible values: \\"development | production | none\\"

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand Down Expand Up @@ -2610,6 +2612,7 @@ exports[`help should show help information using the "help --stats" option: stde
exports[`help should show help information using the "help --stats" option: stdout 1`] = `
"Usage: webpack --stats [value]
Description: It instructs webpack on how to treat the stats e.g. verbose.
Possible values: \\"none | summary | errors-only | errors-warnings | minimal | normal | detailed | verbose\\"

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand Down Expand Up @@ -2678,6 +2681,7 @@ exports[`help should show help information using the "help serve --mode" option:
exports[`help should show help information using the "help serve --mode" option: stdout 1`] = `
"Usage: webpack serve --mode <value>
Description: Defines the mode to pass to webpack.
Possible values: \\"development | production | none\\"

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand Down