Skip to content

Commit

Permalink
feat: actually work with different topicSeparators
Browse files Browse the repository at this point in the history
  • Loading branch information
RodEsp committed Nov 2, 2022
1 parent 75a822a commit 4217bf8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/commands/which.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ export default class Which extends Command {

async run(): Promise<void> {
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'])
Expand Down

0 comments on commit 4217bf8

Please sign in to comment.