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

variadic positional arguments are duplicated if specified through config #2096

Open
aol-nnov opened this issue Dec 14, 2021 · 3 comments
Open
Labels

Comments

@aol-nnov
Copy link

aol-nnov commented Dec 14, 2021

minimal example

const yargs = require('yargs/yargs');

yargs(process.argv.slice(2))
    .parserConfiguration({
        'combine-arrays': true
    })
    .config(
        {
            "sourceIdx": "source",
            "binIdx": [
                "bin1-file",
                "bin2-file"
            ]
        }
    )
    .command('$0 <packageToSeed> [sourceIdx] [binIdx..]',
        'make build sequence from a single package',
        {},
        (argv) => console.log(argv))
    .argv;

invocation: node ./minimal.js qwe

actual output:

{
  _: [],
  sourceIdx: 'source',
  binIdx: [ 'bin1-file', 'bin2-file', 'bin1-file', 'bin2-file' ],
  '$0': 'minimal.js',
  packageToSeed: 'qwe',
  'package-to-seed': 'qwe',
  'bin-idx': [ 'bin1-file', 'bin2-file' ]
}

expected output:

{
  _: [],
  sourceIdx: 'source',
  binIdx: [ 'bin1-file', 'bin2-file' ],
  '$0': 'minimal.js',
  packageToSeed: 'qwe',
  'package-to-seed': 'qwe',
  'bin-idx': [ 'bin1-file', 'bin2-file' ]
}

Can't help but notice that dashed variant of an array contains correct values.

I'm using yargs@17.3.0 and node v12.21.0

@jly36963 jly36963 self-assigned this Dec 15, 2021
@jly36963
Copy link
Contributor

Thanks for the bug report! I'll work on a fix for this

@bcoe
Copy link
Member

bcoe commented May 14, 2022

@jly36963 the fix in #2100 seems to solve the issue when combine-arrays is false, but behaves a bit oddly when it's true. It seems that veriadic arguments are combined with the array defined in the config, but not arguments passed as dash arguments.

@jly36963
Copy link
Contributor

@bcoe Looking now 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants