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

Long hyphenated options aren't recognised as aliases #119

Open
1 task done
chocolateboy opened this issue Jul 19, 2021 · 0 comments
Open
1 task done

Long hyphenated options aren't recognised as aliases #119

chocolateboy opened this issue Jul 19, 2021 · 0 comments

Comments

@chocolateboy
Copy link
Contributor

chocolateboy commented Jul 19, 2021

Issue Type

  • Bug Report

Keywords: options, alias, aliases, hyphen, kebab-case

Description

Long hyphenated options (e.g. --clear-screen) aren't recognised as aliases of short options (e.g. -c) or long non-hyphenated options (e.g. --clear).


Suppose you have a --clear-screen option (as in the README) which can also be called as --clear or -c:

cat ./test.js
const cli = require('cac')()
cli.option('-c, --clear, --clear-screen')
console.log(cli.parse().options)

If this command is called with -c or --clear (or --clearScreen), all three aliases are assigned the value, e.g.:

node ./test.js -c            # { '--': [], c: true, clear: true, clearScreen: true }
node ./test.js --clear       # { '--': [], c: true, clear: true, clearScreen: true }
node ./test.js --clearScreen # { '--': [], c: true, clear: true, clearScreen: true }

But if the command is called with the long hyphenated option, it's treated as an unknown option (the aliases are not assigned the value):

node ./test.js --clear-screen   # { '--': [], clearScreen: true }
node ./test.js --unknown-option # { '--': [], unknownOption: true }

Environment

CAC: 6.7.3
Node: v14.17.3
OS: Linux (Arch)

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