Skip to content

Can't create command with alias to default command #151

@domdomegg

Description

@domdomegg

Issue Type

  • Bug Report
  • Feature Request
  • Other

Expected

cli
  .command("something", "Do something")
  .alias("!")
  .action(async () => {
    console.log("Did something!");
  });

Should log 'Did something!' if you run cli something or cli

Actual

Only logs when running cli something

Possible Solutions

cac/src/CAC.ts

Lines 200 to 210 in abe662b

if (shouldParse) {
// Search the default command
for (const command of this.commands) {
if (command.name === '') {
shouldParse = false
const parsed = this.mri(argv.slice(2), command)
this.setParsedInfo(parsed, command)
this.emit(`command:!`, command)
}
}
}
should use command.isDefaultCommand rather than the name.

We should also add documentation explaining the ! alias.

Info

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions