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

withValue requires '=' for value to be set. #54

Closed
bcoe opened this issue Feb 1, 2022 · 4 comments
Closed

withValue requires '=' for value to be set. #54

bcoe opened this issue Feb 1, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@bcoe
Copy link
Collaborator

bcoe commented Feb 1, 2022

    const parse = parser(['--pow', 'xixxle'], {
      withValue: ['pow']
    })

Parses as:

{
  flags: { pow: true },
  values: { pow: undefined },
  positionals: [ 'xixxle' ]
}

I believe this should be:

{
  flags: { },
  values: { pow: 'xixxle' },
  positionals: [  ]
}
@shadowspawn
Copy link
Collaborator

Speculation: I will try reproducing later, but my first guess is that your shim is not passing through withValue successfully and you are getting zero-config behaviour.

@shadowspawn
Copy link
Collaborator

I am unable to reproduce the problem as described. I see this behaviour:

const { parseArgs } = require('@pkgjs/parseargs');

const parsed = parseArgs(['--pow', 'xixxle'], {
    withValue: ['pow']
  })

console.log(parsed);
% node index.js 
{ flags: { pow: true }, values: { pow: 'xixxle' }, positionals: [] }

(Wondering why there is there an entry for pow in flags? See #38: the README and naming and code are not all in sync! The code is still using existence conventions. Looking forward to making a decision and getting things consistent.)

@bcoe
Copy link
Collaborator Author

bcoe commented Feb 1, 2022

@shadowspawn let me test again against the latest main, I wonder if it's a bug we merged a fix for.

@bcoe
Copy link
Collaborator Author

bcoe commented Feb 3, 2022

I was being silly and not passing the options to the parser.

@bcoe bcoe closed this as completed Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants