yargs / yargs/yargs-parser

Using an equal sign (or not) with an array option changes the value

Open
#368 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
519
Forks
129
Avg merge
1h 34m
Merged PRs (30d)
1

Description

When using the following code:

const yargs = require('yargs')
console.log(yargs.option('opt', { array: true }).parse().opt)

Using a = or not changes the parsed value, which is quite confusing:

$ node yargs.js --opt=""
[]

$ node yargs.js --opt ""
[ '' ]

Using yargs 16.2.0 on Node 15.6.0.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the two commands in the provided yargs.js example, comparing --opt="" with --opt "". Start by tracing the yargs-parser option parsing entry point and identify the intended behavior for an empty array value. Add regression coverage for both forms and verify that the resulting values follow the agreed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.