@@ -13,13 +13,14 @@ import { IPatchSeriesMetadata } from "../lib/patch-series-metadata.js";
13
13
import { IConfig , loadConfig , setConfig } from "../lib/project-config.js" ;
14
14
import path from "path" ;
15
15
16
- const commander = new Command ( ) ;
16
+ let commander = new Command ( ) ;
17
17
const publishRemoteKey = "publishRemote" ;
18
18
19
19
commander
20
20
. 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...] " )
22
22
. description ( "Command-line helper for GitGitGadget" )
23
+ . passThroughOptions ( )
23
24
. option (
24
25
"-g, --git-work-dir [directory]" ,
25
26
"Use a different git.git working directory than specified via `gitgitgadget.workDir`" ,
@@ -33,7 +34,7 @@ commander
33
34
)
34
35
. option ( "-c, --config <string>" , "Use this configuration when using gitgitgadget with a project other than git" , "" )
35
36
. 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) " )
37
38
. parse ( process . argv ) ;
38
39
39
40
interface ICommanderOptions {
@@ -43,10 +44,6 @@ interface ICommanderOptions {
43
44
skipUpdate : boolean | undefined ;
44
45
}
45
46
46
- if ( commander . args . length === 0 ) {
47
- commander . help ( ) ;
48
- }
49
-
50
47
const commandOptions = commander . opts < ICommanderOptions > ( ) ;
51
48
52
49
( async ( ) : Promise < void > => {
@@ -75,6 +72,8 @@ const commandOptions = commander.opts<ICommanderOptions>();
75
72
76
73
const ci = new CIHelper ( await getGitGitWorkDir ( ) , commandOptions . skipUpdate , commandOptions . gitgitgadgetWorkDir ) ;
77
74
75
+ const argv = commander . args ;
76
+ commander = new Command ( ) . version ( "1.0.0" ) ;
78
77
commander
79
78
. usage ( "[options] command" )
80
79
. command ( "update-open-prs" )
@@ -474,7 +473,7 @@ const commandOptions = commander.opts<ICommanderOptions>();
474
473
}
475
474
await ci . handleNewMails ( mailArchiveGitDir , onlyPRs . size ? onlyPRs : undefined ) ;
476
475
} ) ;
477
- await commander . parseAsync ( commander . args , { from : "user" } ) ;
476
+ await commander . parseAsync ( argv , { from : "user" } ) ;
478
477
} ) ( ) . catch ( ( reason : Error ) => {
479
478
console . log ( `Caught error ${ reason } :\n${ reason . stack } \n` ) ;
480
479
process . stderr . write ( `Caught error ${ reason } :\n${ reason . stack } \n` ) ;
0 commit comments