From 4217bf80f28f3e228c359a4795b68809fe5f5d07 Mon Sep 17 00:00:00 2001 From: Rodrigo Espinosa de los Monteros <1084688+RodEsp@users.noreply.github.com> Date: Wed, 2 Nov 2022 15:15:07 -0400 Subject: [PATCH] feat: actually work with different topicSeparators --- src/commands/which.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/commands/which.ts b/src/commands/which.ts index 29c7a6b2..c60f20b4 100644 --- a/src/commands/which.ts +++ b/src/commands/which.ts @@ -6,8 +6,16 @@ export default class Which extends Command { async run(): Promise { const {argv} = await this.parse(Which) - const cmd = this.config.findCommand(argv.join(this.config.topicSeparator), {must: true}) - CliUx.ux.styledHeader(cmd.id) + let command = argv + + if (argv.length === 1 && typeof argv[0] === 'string') { + // If this if statement is true then the command to find was passed in as a single string, e.g. `mycli which "my command"` + // So we must use the topicSeparator to split it into an array + command = argv[0].split(this.config.topicSeparator) + } + + const cmd = this.config.findCommand(command.join(':'), {must: true}) + CliUx.ux.styledHeader(command.join(this.config.topicSeparator)) CliUx.ux.styledObject({ plugin: cmd.pluginName, }, ['plugin'])