Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 3 tasks
domdomegg opened this issue Feb 17, 2023 · 0 comments
Open
1 of 3 tasks

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

domdomegg opened this issue Feb 17, 2023 · 0 comments

Comments

@domdomegg
Copy link

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

domdomegg added a commit to domdomegg/cac that referenced this issue Feb 17, 2023
domdomegg added a commit to domdomegg/cac that referenced this issue Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant