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

Commit 9be0d8c

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #288 from telerik/fatme/fix-dynamic-commands
Generate dynamic commands only if the command starts with dynamic commands prefix
2 parents bc1c11e + 3e2ee56 commit 9be0d8c

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
@@ -108,7 +108,7 @@ export class HtmlHelpService implements IHtmlHelpService {
108108

109109
var availableCommands = this.$injector.getRegisteredCommandsNames(false).sort();
110110
this.$logger.trace("List of registered commands: %s", availableCommands.join(", "));
111-
if(commandName && !_.contains(availableCommands, commandName)) {
111+
if(commandName && _.startsWith(commandName, this.$commandsServiceProvider.dynamicCommandsPrefix) && !_.contains(availableCommands, commandName)) {
112112
var dynamicCommands = this.$commandsServiceProvider.getDynamicCommands().wait();
113113
if(!_.contains(dynamicCommands, commandName)) {
114114
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)