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

No single flag support? #32

Closed
reggi opened this issue Jun 26, 2016 · 7 comments · Fixed by #39
Closed

No single flag support? #32

reggi opened this issue Jun 26, 2016 · 7 comments · Fixed by #39

Comments

@reggi
Copy link

reggi commented Jun 26, 2016

I see there's alias support, but this behavior below is kind of unexpected. Would love to know what others think here. Shouldn't minimist and dargs be inter-operable?

console.log(process.argv.slice(2))
console.log(minimist(process.argv.slice(2)))
console.log(dargs(minimist(process.argv.slice(2))))
console.log(minimist(dargs(minimist(process.argv.slice(2)))))
[ 'list', '--animal', 'meow', '-A', '-L', '-P', '-H', '-A' ]
{ _: [ 'list' ],
  animal: 'meow',
  A: true,
  L: true,
  P: true,
  H: true }
[ '--animal=meow', '---a', '---l', '---p', '---h', 'list' ]
{ _: [],
  animal: 'meow',
  '-a': true,
  '-l': true,
  '-p': true,
  '-h': 'list' }
@sindresorhus
Copy link
Owner

Do you have an actual need for this? Explain your use-case. There's no direct single-flag support as it has never been requested and I personally don't see the use-case. When would you ever want to support doing {a: true} in your API?

@reggi
Copy link
Author

reggi commented Jun 26, 2016

Hey @sindresorhus, thanks for the quick reply.

I'm proxying some bash commands and I need to parse using minimist and then pass the parent commands along to a child process again.

There are a couple of other options I found that follow minimist. Feel free to close.

@sindresorhus
Copy link
Owner

Alright. I would accept a PR if you want this here, but probably easier to use any of those packages.

@tunnckoCore
Copy link

tunnckoCore commented Jun 17, 2019

@sindresorhus any reconsideration about that? It's definitely a one line change 🛩️

@sindresorhus
Copy link
Owner

@tunnckoCore I already accepted it if anyone wants to do a PR with docs and tests.

@tunnckoCore
Copy link

tunnckoCore commented Jun 17, 2019

Oooh, yea, miss-looked your last comment :) I'll PR then.

@tunnckoCore
Copy link

tunnckoCore commented Jun 17, 2019

@sindresorhus, probably behind some option e.g. allowSingleFlags? Otherwise it sounds like a breaking change.
Because most of the tests are failing. Which is normal - e.g. { a: 123 } now becomes ['-a=123'].

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 a pull request may close this issue.

3 participants