豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 79337ec

Browse files
authored
chore: tweak CLI (#1088)
- document optional params - remove customHelp
1 parent baa80f9 commit 79337ec

File tree

2 files changed

+15
-122
lines changed

2 files changed

+15
-122
lines changed

src/bin/chrome-devtools.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ import type {CallToolResult} from '../third_party/index.js';
2424
import {VERSION} from '../version.js';
2525

2626
import {commands} from './cliDefinitions.js';
27-
import {generateCustomHelp} from './customHelp.js';
28-
29-
const argv = hideBin(process.argv);
30-
31-
if (argv.length === 0 || argv[0] === '--custom-help') {
32-
console.log(generateCustomHelp(VERSION, commands));
33-
process.exit(0);
34-
}
3527

3628
async function start(args: string[]) {
3729
const combinedArgs = [...args, ...defaultArgs];
@@ -41,13 +33,18 @@ async function start(args: string[]) {
4133

4234
const defaultArgs = ['--viaCli', '--experimentalStructuredContent'];
4335

44-
const y = yargs(argv)
36+
const y = yargs(hideBin(process.argv))
4537
.scriptName('chrome-devtools')
4638
.showHelpOnFail(true)
39+
.usage('chrome-devtools <command> [...args] --flags')
40+
.usage(
41+
`Run 'chrome-devtools <command> --help' for help on the specific command.`,
42+
)
4743
.demandCommand()
4844
.version(VERSION)
4945
.strict()
50-
.help(true);
46+
.help(true)
47+
.wrap(120);
5148

5249
y.command(
5350
'start',
@@ -84,7 +81,6 @@ y.command('status', 'Checks if chrome-devtools-mcp is running', async () => {
8481
y.command('stop', 'Stop chrome-devtools-mcp if any', async () => {
8582
if (!isDaemonRunning()) {
8683
process.exit(0);
87-
return;
8884
}
8985
await stopDaemon();
9086
process.exit(0);
@@ -96,11 +92,19 @@ for (const [commandName, commandDef] of Object.entries(commands)) {
9692
name => args[name].required,
9793
);
9894

95+
const optionalArgNames = Object.keys(args).filter(
96+
name => !args[name].required,
97+
);
98+
9999
let commandStr = commandName;
100100
for (const arg of requiredArgNames) {
101101
commandStr += ` <${arg}>`;
102102
}
103103

104+
for (const arg of optionalArgNames) {
105+
commandStr += ` [--${arg}]`;
106+
}
107+
104108
y.command(
105109
commandStr,
106110
commandDef.description,

src/bin/customHelp.ts

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)