yargs / yargs/yargs-parser

greedy arrays seems not work

Open
#393 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

const parser = require('yargs-parser')

const args = parser(process.argv.slice(2), {
    //array: ['foo'],
    configuration: {
        "greedy-arrays": true
    }
})
console.log(args);
]$ v-cli --foo apple banana cat
{ _: [ 'banana', 'cat' ], foo: 'apple' }

how to get { _: [ ], foo: ['apple', 'banana', 'cat' ] } Instead of specifying array: ['foo'],

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 running the provided yargs-parser reproduction with configuration set to greedy-arrays and compare it with the explicit array option. Trace how positional values are assigned when greedy-arrays is enabled. Done means the shown command produces an empty _ array and places all three values in foo, without requiring array: ['foo'].

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.