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

consider an option to enforce correct type for default #23

Open
ORESoftware opened this issue May 18, 2016 · 2 comments
Open

consider an option to enforce correct type for default #23

ORESoftware opened this issue May 18, 2016 · 2 comments

Comments

@ORESoftware
Copy link
Contributor

ORESoftware commented May 18, 2016

with this config

   {
        names: ['match'],
        type: 'arrayOfString',
        help: 'Use this to filter input to match the given JS regex',
        default: 'fixture'
    },

without a --match option at the command line

the match option will default to 'fixture'...

but the match option will be just a string 'fixture'

dashdash should probably either (1) coerce it into an array or (2) throw an error

in other words, the below works as expected, but the above does not

   {
        names: ['match'],
        type: 'arrayOfString',
        help: 'Use this to filter input to match the given JS regex',
        default: ['fixture']
    },

up to you, makes sense to leave it as is

@ORESoftware
Copy link
Contributor Author

Seems like this is a bug?

@trentm
Copy link
Owner

trentm commented Oct 20, 2016

If anything I think that should fail when the option spec is read, because the given 'default' doesn't match the type. That would either need to be off by default or only in a new major dashdash version.

@trentm trentm changed the title minor bug - please coerce to array consider an option to enforce correct type for default Oct 20, 2016
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