Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 3e2ee56

Browse files
committed
Generate dynamic commands only if the command starts with dynamic commands prefix
1 parent 115b8b2 commit 3e2ee56

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

definitions/commands-service.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ interface ICommandsService {
66
}
77

88
interface ICommandsServiceProvider {
9+
dynamicCommandsPrefix: string;
910
getDynamicCommands(): IFuture<string[]>;
1011
generateDynamicCommands(): IFuture<void>;
1112
registerDynamicSubCommands(): void;

services/commands-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class CommandsService implements ICommandsService {
113113

114114
this.$errors.fail("Unable to execute command '%s'. Use '$ %s %s --help' for help.", beautifiedName, this.$staticConfig.CLIENT_NAME.toLowerCase(), beautifiedName);
115115
return false;
116-
} else if(!isDynamicCommand){
116+
} else if(!isDynamicCommand && _.startsWith(commandName, this.$commandsServiceProvider.dynamicCommandsPrefix)){
117117
if(_.any(this.$commandsServiceProvider.getDynamicCommands().wait())) {
118118
this.$commandsServiceProvider.generateDynamicCommands().wait();
119119
return this.canExecuteCommand(commandName, commandArguments, true).wait();

services/html-help-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class HtmlHelpService implements IHtmlHelpService {
102102

103103
var availableCommands = this.$injector.getRegisteredCommandsNames(false).sort();
104104
this.$logger.trace("List of registered commands: %s", availableCommands.join(", "));
105-
if(commandName && !_.contains(availableCommands, commandName)) {
105+
if(commandName && _.startsWith(commandName, this.$commandsServiceProvider.dynamicCommandsPrefix) && !_.contains(availableCommands, commandName)) {
106106
var dynamicCommands = this.$commandsServiceProvider.getDynamicCommands().wait();
107107
if(!_.contains(dynamicCommands, commandName)) {
108108
this.$errors.failWithoutHelp("Unknown command '%s'. Try '$ %s help' for a full list of supported commands.", commandName, this.$staticConfig.CLIENT_NAME.toLowerCase());

0 commit comments

Comments
 (0)