Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/bin/chrome-devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ import type {CallToolResult} from '../third_party/index.js';
import {VERSION} from '../version.js';

import {commands} from './cliDefinitions.js';
import {generateCustomHelp} from './customHelp.js';

const argv = hideBin(process.argv);

if (argv.length === 0 || argv[0] === '--custom-help') {
console.log(generateCustomHelp(VERSION, commands));
process.exit(0);
}

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

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

const y = yargs(argv)
const y = yargs(hideBin(process.argv))
.scriptName('chrome-devtools')
.showHelpOnFail(true)
.usage('chrome-devtools <command> [...args] --flags')
.usage(
`Run 'chrome-devtools <command> --help' for help on the specific command.`,
)
.demandCommand()
.version(VERSION)
.strict()
.help(true);
.help(true)
.wrap(120);

y.command(
'start',
Expand Down Expand Up @@ -84,7 +81,6 @@ y.command('status', 'Checks if chrome-devtools-mcp is running', async () => {
y.command('stop', 'Stop chrome-devtools-mcp if any', async () => {
if (!isDaemonRunning()) {
process.exit(0);
return;
}
await stopDaemon();
process.exit(0);
Expand All @@ -96,11 +92,19 @@ for (const [commandName, commandDef] of Object.entries(commands)) {
name => args[name].required,
);

const optionalArgNames = Object.keys(args).filter(
name => !args[name].required,
);

let commandStr = commandName;
for (const arg of requiredArgNames) {
commandStr += ` <${arg}>`;
}

for (const arg of optionalArgNames) {
commandStr += ` [--${arg}]`;
}

y.command(
commandStr,
commandDef.description,
Expand Down
111 changes: 0 additions & 111 deletions src/bin/customHelp.ts

This file was deleted.

Loading