@@ -24,14 +24,6 @@ import type {CallToolResult} from '../third_party/index.js';
2424import { VERSION } from '../version.js' ;
2525
2626import { 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
3628async function start ( args : string [ ] ) {
3729 const combinedArgs = [ ...args , ...defaultArgs ] ;
@@ -41,13 +33,18 @@ async function start(args: string[]) {
4133
4234const 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
5249y . command (
5350 'start' ,
@@ -84,7 +81,6 @@ y.command('status', 'Checks if chrome-devtools-mcp is running', async () => {
8481y . 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 ,
0 commit comments