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

The option method does not add the aliases to cmd.default object #17

Closed
tunnckoCore opened this issue May 18, 2018 · 1 comment
Closed

Comments

@tunnckoCore
Copy link

Heya.

I know that in that cmd or "command object" we have both .alias and .default properties. But it isn't easy to merged them both in one single object.

For example

cli
  .command('foo', 'abc de')
  .option('-f, --format', 'some formatting', 'bar')
  .option('--fix', 'barry dazzle', true)

so they looks like

alias: { f: [ 'format' ] }
default: { fix: true, format: 'bar' }

So, it isn't possible to detect what default has what aliases. Would it be better the keys of alias object to be the name format in that case and its value to be its aliases? I believe that defining aliases in minimist (and probably mri) can accept both variants.

I want to merge them in one final object that is the same as "argv", same as the parsed result of mri/minimist, except the _.

@tunnckoCore
Copy link
Author

Currently we should do something like that

Object.keys(cmd.alias).forEach((key) => {
  cmd.alias[key].forEach((alias) => {
    argv[key] = argv[alias];
  });
});

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

2 participants