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

feat: coerce full array instead of each element #51

Merged
merged 2 commits into from
Aug 13, 2016
Merged

Conversation

nexdrew
Copy link
Member

@nexdrew nexdrew commented Aug 12, 2016

Fixes #50.

As a bonus, this also means coercion can apply to argv._. Here's an example:

var parse = require('yargs-parser')
var argv = parse(process.argv.slice(2), {
  coerce: {
    _: function (arg) {
      // do something special here
      return arg
    }
  }
})
console.log(argv)

This works with an explicit string: ['_'] option too (the coerce function would be guaranteed to be given an array of strings).

Note that coercion for implicit arrays (options parsed with multiple values but without array config) still happens per element.

@nexdrew nexdrew mentioned this pull request Aug 13, 2016
4 tasks
@bcoe bcoe merged commit cc4dc56 into master Aug 13, 2016
@bcoe bcoe deleted the array-coercion branch August 13, 2016 19:38
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

Successfully merging this pull request may close these issues.

2 participants