yargs / yargs/yargs-parser

Using an equal sign with short/alias options and an empty string

Open
#367 0 comments 1 reaction 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

Short options do not seem to work when using an equal sign and an empty string.

Example:

// yargs.js
const yargs = require('yargs')
console.log(yargs.option('opt', { alias: 'o' }).parse())
$ node yargs.js -o ""
{ _: [], o: '', opt: '', '$0': 'yargs.js' }
$ node yargs.js -o=""
{ _: [], o: true, opt: true, '=': true, '$0': 'yargs.js' }

Note that this works correctly when not using an empty string:

$ node yargs.js -o "value"
{ _: [], o: 'value', opt: 'value', '$0': 'yargs.js' }
$ node yargs.js -o="value"
{ _: [], o: 'value', opt: 'value', '$0': 'yargs.js' }

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

Start by reproducing the two command-line forms in the reported yargs.js example, comparing -o "" with -o="" and the resulting alias values. Done means the equals-sign form preserves the empty string for both o and opt and does not add an unexpected '=' key.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.