Skip to content

Commit 1514fad

Browse files
committed
refactor(cli): improve help readability
- Use bold instead of cyan for option/command terms (cyan was hard to read) - Collapse the indented 'Alternative usage' line into a single Usage line showing both supported syntaxes: 'webpack [entries...] [options] | webpack [command] [options]' Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01TgNXy9shNnZEnbCfsSbtiQ
1 parent 5650a43 commit 1514fad

2 files changed

Lines changed: 12 additions & 20 deletions

File tree

packages/webpack-cli/src/webpack-cli.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ class WebpackCLI {
13771377
value === "--version" ||
13781378
value === "-h" ||
13791379
value === "--help";
1380-
const { bold, cyan } = this.colors;
1380+
const { bold } = this.colors;
13811381
// Shared "chrome" used to render the help screens. These are purely visual:
13821382
// colors collapse to plain strings when colors are disabled (e.g. piped output
13831383
// or `--no-color`), so the textual structure stays stable for scripts.
@@ -1414,9 +1414,8 @@ class WebpackCLI {
14141414
}
14151415

14161416
if (isGlobalHelp) {
1417-
return `${parentCmdNames}${command.usage()}\n${INDENT}${bold(
1418-
"Alternative usage to run commands:",
1419-
)} ${parentCmdNames}[command] [options]`;
1417+
// Show both supported invocation syntaxes on a single line.
1418+
return `${parentCmdNames}${command.usage()} | ${parentCmdNames}[command] [options]`;
14201419
}
14211420

14221421
return `${parentCmdNames}${command.name()}|${command
@@ -1464,14 +1463,14 @@ class WebpackCLI {
14641463
const formatItem = (term: string, description: string) => {
14651464
if (description) {
14661465
return helper.formatItem(
1467-
cyan(term),
1466+
bold(term),
14681467
helper.padWidth(command, helper),
14691468
description,
14701469
helper,
14711470
);
14721471
}
14731472

1474-
return `${INDENT}${cyan(term)}`;
1473+
return `${INDENT}${bold(term)}`;
14751474
};
14761475

14771476
const formatList = (textArray: string[]) => textArray.join("\n");

test/help/__snapshots__/help.test.js.snap.devServer5.webpack5

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ exports[`help should show help information and respect the "--color" flag using
9898
────────────────────────────────────────────────────────────────────────
9999
The build tool for modern web applications.
100100

101-
Usage: webpack [entries...] [options]
102-
Alternative usage to run commands: webpack [command] [options]
101+
Usage: webpack [entries...] [options] | webpack [command] [options]
103102

104103
Options
105104
────────────────────────────────────────────────────────────────────────
@@ -158,8 +157,7 @@ exports[`help should show help information and respect the "--no-color" flag usi
158157
────────────────────────────────────────────────────────────────────────
159158
The build tool for modern web applications.
160159

161-
Usage: webpack [entries...] [options]
162-
Alternative usage to run commands: webpack [command] [options]
160+
Usage: webpack [entries...] [options] | webpack [command] [options]
163161

164162
Options
165163
────────────────────────────────────────────────────────────────────────
@@ -218,8 +216,7 @@ exports[`help should show help information and taking precedence when "--help" a
218216
────────────────────────────────────────────────────────────────────────
219217
The build tool for modern web applications.
220218

221-
Usage: webpack [entries...] [options]
222-
Alternative usage to run commands: webpack [command] [options]
219+
Usage: webpack [entries...] [options] | webpack [command] [options]
223220

224221
Options
225222
────────────────────────────────────────────────────────────────────────
@@ -2610,8 +2607,7 @@ exports[`help should show help information using command syntax: stdout 1`] = `
26102607
────────────────────────────────────────────────────────────────────────
26112608
The build tool for modern web applications.
26122609

2613-
Usage: webpack [entries...] [options]
2614-
Alternative usage to run commands: webpack [command] [options]
2610+
Usage: webpack [entries...] [options] | webpack [command] [options]
26152611

26162612
Options
26172613
────────────────────────────────────────────────────────────────────────
@@ -2700,8 +2696,7 @@ exports[`help should show help information using the "--help" option: stdout 1`]
27002696
────────────────────────────────────────────────────────────────────────
27012697
The build tool for modern web applications.
27022698

2703-
Usage: webpack [entries...] [options]
2704-
Alternative usage to run commands: webpack [command] [options]
2699+
Usage: webpack [entries...] [options] | webpack [command] [options]
27052700

27062701
Options
27072702
────────────────────────────────────────────────────────────────────────
@@ -3058,8 +3053,7 @@ exports[`help should show the same information using the "--help" option and com
30583053
────────────────────────────────────────────────────────────────────────
30593054
The build tool for modern web applications.
30603055

3061-
Usage: webpack [entries...] [options]
3062-
Alternative usage to run commands: webpack [command] [options]
3056+
Usage: webpack [entries...] [options] | webpack [command] [options]
30633057

30643058
Options
30653059
────────────────────────────────────────────────────────────────────────
@@ -3116,8 +3110,7 @@ exports[`help should show the same information using the "--help" option and com
31163110
────────────────────────────────────────────────────────────────────────
31173111
The build tool for modern web applications.
31183112

3119-
Usage: webpack [entries...] [options]
3120-
Alternative usage to run commands: webpack [command] [options]
3113+
Usage: webpack [entries...] [options] | webpack [command] [options]
31213114

31223115
Options
31233116
────────────────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)