parser icon indicating copy to clipboard operation
parser copied to clipboard

feat: Add 'singleValue' flag option to assign only one value per multiple flag

Open cxam opened this issue 4 years ago • 5 comments

This feature aims to address the issue outlined in https://github.com/oclif/oclif/issues/190 to only allow a single value to be assigned for each flag that has the multiple option set. It's a non-breaking change that requires you to include the singleValue boolean in your flag options.

In the command cmd -a foo bar, it's generally accepted that bar becomes a positional argument and should be the default behaviour. Unfortunately, the PR that broke default behaviour has been part of this project for a while now and I feel providing the user an option to change this back would be the best course of action unless a breaking release is planned for oclif.

If this goes through, I'll update and push the relevant changes to the docs repository.

cxam avatar May 18 '20 19:05 cxam

Codecov Report

Merging #79 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master     #79   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files           1       1           
  Lines          46      29   -17     
  Branches       21      14    -7     
======================================
+ Misses         46      29   -17     
Impacted Files Coverage Δ
src/validate.ts 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update dfb4423...9de72fb. Read the comment docs.

codecov[bot] avatar May 18 '20 19:05 codecov[bot]

Any update on this PR? This is a sorely needed improvement.

vasinov avatar Jun 15 '20 23:06 vasinov

This seems like a great approach to the fix. Hopefully this gets reviewed and merged soon.

srlowe avatar Jun 26 '20 12:06 srlowe

@cxam thanks for the PR! $ cli foo -a foo bar shouldn't pass bar as a flag. I want to revert that PR's behavior. I'll put this on our project board for looking at next.

RasPhilCo avatar Jul 02 '20 19:07 RasPhilCo

I have created a patch of this PR against v3.8.5, if using yarn, you can add the following yarn resolution to packages.json and get this change today while we wait for this to get merged:

  "resolutions": {
    "@oclif/parser": "https://github.com/caleblloyd/oclif-parser-patch-single-value#v3.8.5"
  }

caleblloyd avatar Oct 08 '20 16:10 caleblloyd