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

bug: dashdash doesn't check if default values match the type of arg #43

Open
ORESoftware opened this issue Apr 19, 2018 · 2 comments
Open

Comments

@ORESoftware
Copy link
Contributor

ORESoftware commented Apr 19, 2018

Say I have this:

const opts = [
 {
    names: ['force', 'f'],
    type: 'bool',
    help: 'Force everything (and say yes to everything).',
    default: 'foobar'  // should be a boolean, but we give a string
  }
]

last time I checked, dashdash will not complain.

I am guessing that this would also fly, etc:

const opts = [
 {
    names: ['force', 'f'],
    type: 'string',
    help: 'Force everything (and say yes to everything).',
    default:  [1,2,3]  // should be a string, but we have an array of numbers instead
  }
]

the type of the default value should match the type? Or perhaps at least log a warning?

@karfau
Copy link

karfau commented Jan 31, 2020

@ORESoftware How is this different from #23 ?

@robations
Copy link

robations commented Dec 21, 2023

I'll note that the current types (@types/dashdash@1.14.3 at time of writing) indicate that default should be string | undefined, which suggests the option default is pre-parsing?

If that's the case, I'm not sure if you'd be expected to write, say, default: "false" for a boolean (though I'd guess this is a trivial example).

Not sure whether to comment on both issues...

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

3 participants