Skip to content
Snippets Groups Projects
Commit ce0adf70 authored by michael.minelli's avatar michael.minelli
Browse files

CommanderApp => Add possibility to disable hooks for some commands

parent a4d97e4f
Branches
Tags
No related merge requests found
Pipeline #30163 passed
...@@ -14,7 +14,21 @@ import SessionCommand from './auth/SessionCommand'; ...@@ -14,7 +14,21 @@ import SessionCommand from './auth/SessionCommand';
class CommanderApp { class CommanderApp {
program: Command = new Command(); public program: Command = new Command();
private readonly commandHookDisabled: Array<string> = [ 'completion' ];
private hasToExecuteHook(actionCommand: Command): boolean {
if ( actionCommand.parent == null ) {
return true;
} else {
if ( this.commandHookDisabled.includes(actionCommand.name()) ) {
return false;
}
return this.hasToExecuteHook(actionCommand.parent);
}
}
constructor() { constructor() {
this.program this.program
...@@ -30,11 +44,16 @@ class CommanderApp { ...@@ -30,11 +44,16 @@ class CommanderApp {
.option('-H, --host <string>', 'override the Dojo API endpoint', ClientsSharedConfig.apiURL) .option('-H, --host <string>', 'override the Dojo API endpoint', ClientsSharedConfig.apiURL)
.option('-I, --interactive', 'show interactive interface when available', Config.interactiveMode) .option('-I, --interactive', 'show interactive interface when available', Config.interactiveMode)
.addOption(new Option('--debug').hideHelp()) .addOption(new Option('--debug').hideHelp())
.hook('preAction', () => { .hook('preAction', (_thisCommand: Command, actionCommand: Command) => {
this.warnDevelopmentVersion(); if ( this.hasToExecuteHook(actionCommand) ) {
}).hook('postAction', () => { this.warnDevelopmentVersion();
this.informNewVersion(); }
}); })
.hook('postAction', (_thisCommand: Command, actionCommand: Command) => {
if ( this.hasToExecuteHook(actionCommand) ) {
this.informNewVersion();
}
});
this.program.on('option:host', () => { this.program.on('option:host', () => {
ClientsSharedConfig.apiURL = this.program.opts().host; ClientsSharedConfig.apiURL = this.program.opts().host;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment