This repository was archived by the owner on Aug 22, 2023. It is now read-only.
File tree 1 file changed +10
-6
lines changed
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -101,14 +101,9 @@ export default abstract class Command {
101
101
102
102
protected async init ( argv : string [ ] , opts : Config . ICommandOptions ) {
103
103
this . config = opts . config || await Config . read ( { root : opts . root || parentModule ! } )
104
- g [ 'http-call' ] = g [ 'http-call' ] || { }
105
- g [ 'http-call' ] ! . userAgent = this . config . userAgent
106
- this . debug = require ( 'debug' ) ( `cli:command:${ this . ctor . id || this . config . name } ` )
104
+ this . initDebug ( )
107
105
this . debug ( 'init version: %s argv: %o' , this . ctor . _base , argv )
108
106
cli . config . context . command = _ . compact ( [ this . ctor . id , ...argv ] ) . join ( ' ' )
109
- cli . config . context . version = this . config . userAgent
110
- cli . config . debug = ! ! this . config . debug
111
- cli . config . errlog = this . config . errlog
112
107
try {
113
108
const parse = await deps . Parser . parse ( {
114
109
argv,
@@ -127,6 +122,15 @@ export default abstract class Command {
127
122
}
128
123
}
129
124
125
+ protected initDebug ( ) {
126
+ g [ 'http-call' ] = g [ 'http-call' ] || { }
127
+ g [ 'http-call' ] ! . userAgent = this . config . userAgent
128
+ this . debug = require ( 'debug' ) ( `@dxcli/command:${ this . ctor . id || this . config . name } ` )
129
+ cli . config . context . version = this . config . userAgent
130
+ if ( this . config . debug ) cli . config . debug = true
131
+ cli . config . errlog = this . config . errlog
132
+ }
133
+
130
134
protected async done ( ) {
131
135
try {
132
136
await cli . done ( )
You can’t perform that action at this time.
0 commit comments