Skip to content

coercion in yargs? #191

Closed
Closed

Description

@xgbuils

Is there something like coercion in yargs?

I want to use for range arguments.

Thank you.

Activity

  1. xgbuils commented on Jul 8, 2015

    @xgbuils
    Author

    Hi?

    I asked this because if this feature does not exists I'm interested to implement it. And, maybe, somebody could suggest the name of method. I don't like coercion name. I suggest transform method.

    Example:

    var argv = require('yargs')
        .tranform('r', function (value) {
            var arr = value.split('..')
            return {
                min: arr[0],
                max: arr[1]
            }
        })
        .argv
    console.log(argv)

    And then:

    ./script.js -r 1..3
    {
        r: { min: 1, max: 3}
    }
  2. bcoe commented on Jul 10, 2015

    @bcoe
    Member

    Hey @xgbuils, haven't had a chance to dig into this issue yet but I'll be hacking on yargs a bit this weekend and will get you some feedback.

  3. xgbuils commented on Jul 10, 2015

    @xgbuils
    Author

    Thanks, @bcoe

  4. bcoe commented on Jul 3, 2016

    @bcoe
    Member

    closing in favor of #535

    let's actually tackle this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions