@@ -13,13 +13,14 @@ import { IPatchSeriesMetadata } from "../lib/patch-series-metadata.js";
1313import { IConfig , loadConfig , setConfig } from "../lib/project-config.js" ;
1414import path from "path" ;
1515
16- const commander = new Command ( ) ;
16+ let commander = new Command ( ) ;
1717const publishRemoteKey = "publishRemote" ;
1818
1919commander
2020 . version ( "1.0.0" )
21- . usage ( "[options] ( update-open-prs | lookup-upstream-commit | annotate-commit <pr-number> <original> <git.git> ) " )
21+ . usage ( "[options] <command> [args...] " )
2222 . description ( "Command-line helper for GitGitGadget" )
23+ . passThroughOptions ( )
2324 . option (
2425 "-g, --git-work-dir [directory]" ,
2526 "Use a different git.git working directory than specified via `gitgitgadget.workDir`" ,
@@ -33,7 +34,7 @@ commander
3334 )
3435 . option ( "-c, --config <string>" , "Use this configuration when using gitgitgadget with a project other than git" , "" )
3536 . option ( "-s, --skip-update" , "Do not update the local refs (useful for debugging)" )
36- . argument ( "[args...]" , "command and arguments" )
37+ . argument ( "[args...]" , "command arguments (call `list -h` for more information) " )
3738 . parse ( process . argv ) ;
3839
3940interface ICommanderOptions {
@@ -43,10 +44,6 @@ interface ICommanderOptions {
4344 skipUpdate : boolean | undefined ;
4445}
4546
46- if ( commander . args . length === 0 ) {
47- commander . help ( ) ;
48- }
49-
5047const commandOptions = commander . opts < ICommanderOptions > ( ) ;
5148
5249( async ( ) : Promise < void > => {
@@ -75,6 +72,8 @@ const commandOptions = commander.opts<ICommanderOptions>();
7572
7673 const ci = new CIHelper ( await getGitGitWorkDir ( ) , commandOptions . skipUpdate , commandOptions . gitgitgadgetWorkDir ) ;
7774
75+ const argv = commander . args ;
76+ commander = new Command ( ) . version ( "1.0.0" ) ;
7877 commander
7978 . usage ( "[options] command" )
8079 . command ( "update-open-prs" )
@@ -474,7 +473,7 @@ const commandOptions = commander.opts<ICommanderOptions>();
474473 }
475474 await ci . handleNewMails ( mailArchiveGitDir , onlyPRs . size ? onlyPRs : undefined ) ;
476475 } ) ;
477- await commander . parseAsync ( commander . args , { from : "user" } ) ;
476+ await commander . parseAsync ( argv , { from : "user" } ) ;
478477} ) ( ) . catch ( ( reason : Error ) => {
479478 console . log ( `Caught error ${ reason } :\n${ reason . stack } \n` ) ;
480479 process . stderr . write ( `Caught error ${ reason } :\n${ reason . stack } \n` ) ;
0 commit comments