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'])