11import * as queue from "./queue" ;
22import * as path from "path" ;
3+ import { hook } from "./helpers" ;
34
45export class CommandDispatcher implements ICommandDispatcher {
56 constructor ( private $logger : ILogger ,
7+ // required by the hooksService
8+ protected $injector : IInjector ,
69 private $cancellation : ICancellationService ,
710 private $commandsService : ICommandsService ,
811 private $staticConfig : Config . IStaticConfig ,
@@ -24,7 +27,7 @@ export class CommandDispatcher implements ICommandDispatcher {
2427 }
2528
2629 let commandName = this . getCommandName ( ) ;
27- const commandArguments = this . $options . argv . _ . slice ( 1 ) ;
30+ let commandArguments = this . $options . argv . _ . slice ( 1 ) ;
2831 const lastArgument : string = _ . last ( commandArguments ) ;
2932
3033 if ( this . $options . help ) {
@@ -36,6 +39,8 @@ export class CommandDispatcher implements ICommandDispatcher {
3639 commandName = "help" ;
3740 }
3841
42+ ( { commandName, commandArguments, argv : process . argv } = await this . resolveCommand ( commandName , commandArguments , process . argv ) ) ;
43+
3944 await this . $cancellation . begin ( "cli" ) ;
4045
4146 await this . $commandsService . tryExecuteCommand ( commandName , commandArguments ) ;
@@ -45,6 +50,12 @@ export class CommandDispatcher implements ICommandDispatcher {
4550 return this . $commandsService . completeCommand ( ) ;
4651 }
4752
53+ @hook ( "resolveCommand" )
54+ private async resolveCommand ( commandName : string , commandArguments : string [ ] , argv : string [ ] ) {
55+ // just a hook point
56+ return { commandName, commandArguments, argv } ;
57+ }
58+
4859 private getCommandName ( ) : string {
4960 const remaining : string [ ] = this . $options . argv . _ ;
5061 if ( remaining . length > 0 ) {
0 commit comments