@@ -4,6 +4,8 @@ import {HelpBase} from '@oclif/plugin-help'
4
4
import { Command } from '.'
5
5
import { getHelpClass } from '@oclif/plugin-help'
6
6
7
+ const ROOT_INDEX_CMD_ID = ''
8
+
7
9
export class Main extends Command {
8
10
static run ( argv = process . argv . slice ( 2 ) , options ?: Config . LoadOptions ) {
9
11
return super . run ( argv , options || ( module . parent && module . parent . parent && module . parent . parent . filename ) || __dirname )
@@ -16,19 +18,23 @@ export class Main extends Command {
16
18
}
17
19
18
20
async run ( ) {
19
- const [ id , ...argv ] = this . argv
21
+ let [ id , ...argv ] = this . argv
20
22
this . parse ( { strict : false , '--' : false , ...this . ctor as any } )
21
23
if ( ! this . config . findCommand ( id ) ) {
22
24
const topic = this . config . findTopic ( id )
23
25
if ( topic ) return this . _help ( )
26
+ if ( this . config . findCommand ( ROOT_INDEX_CMD_ID ) ) {
27
+ id = ROOT_INDEX_CMD_ID
28
+ argv = this . argv
29
+ }
24
30
}
25
31
await this . config . runCommand ( id , argv )
26
32
}
27
33
28
34
protected _helpOverride ( ) : boolean {
29
35
if ( [ '-v' , '--version' , 'version' ] . includes ( this . argv [ 0 ] ) ) return this . _version ( ) as any
30
36
if ( [ '-h' , 'help' ] . includes ( this . argv [ 0 ] ) ) return true
31
- if ( this . argv . length === 0 ) return true
37
+ if ( this . argv . length === 0 && ! this . config . findCommand ( ROOT_INDEX_CMD_ID ) ) return true
32
38
for ( const arg of this . argv ) {
33
39
if ( arg === '--help' ) return true
34
40
if ( arg === '--' ) return false
0 commit comments