jorgebucaran/getopts

Returning the "cooked" args

zkochan opened this issue · 7 comments

I want to use getopts in pnpm. We currently use nopt (like npm) and it returns the cooked (expanded) args

We'd need this to be returned by getopts to make the switch.

getOpts(['install', '-P'], {alias: {P: 'save-prod'}})
> {_: ['install'], 'save-prod': true, cooked: ['install', '--save-prod']}

would it be ok to have this feature in getopts or should there be some mapping outside of getopts to get the cooked args?

Seems like we'll have to stick with nopt. There are other issues. Like getopts parses install --save-optional some-pkg not the way we need.

Like getopts parses install --save-optional some-pkg not the way we need.

What's your expected output?

 {_: ['install', 'some-pkg'], 'save-optional': true, cooked: ['install', '--save-optional', 'some-pkg']}

currently it parses it as if save-optional was some-pkg. Oh, I could use https://github.com/JorgeBucaran/getopts#optionsboolean

Yup. By default, --option setting is parsed as option: 'setting', and -abc is {a: true, b: true, c: true}. You've got to use the boolean option to configure it.

@zkochan Were you able to fix the problem or are there still other issues?

I've stick with nopt but I will revisit getopts

Sure. If you do try it out and need help adapting from nopt just let me know. Cheers!