yargs / yargs/yargs-parser

Unable to combine count with environment variables

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

Nobody has claimed this yet.

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

Description

There can be only one key for each environment variable. This means a counted option can’t be set this way.

I suggest to change the behaviour of count so that environment variables representing the count, can be set as numbers.

E.g. Given the following option

const yargs = require('yargs');

yargs
  .option('verbose', {
    alias: 'v',
    describe: 'Increase verbosity',
    type: 'count',
  });
VERBOSE=3 ./my-app

would be equivalent to

./my-app -vvv

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 tracing how yargs-parser handles counted options and environment-variable values. Verify that VERBOSE=3 produces the same parsed count as -vvv, and add or update coverage for the example behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.