Skip to content

fix: only use arrays in results for multiples - #42

Merged
bcoe merged 3 commits into
pkgjs:mainfrom
shadowspawn:feature/fix-arrays
Jan 23, 2022
Merged

fix: only use arrays in results for multiples#42
bcoe merged 3 commits into
pkgjs:mainfrom
shadowspawn:feature/fix-arrays

Conversation

@shadowspawn

@shadowspawn shadowspawn commented Jan 23, 2022

Copy link
Copy Markdown
Collaborator

In the old parse results, values[option] is always an array whether or not multiple is used. This PR makes it so an array is not used unless the option is listed in multiple, in which case values[option] is an array from the first value added.

Fixes #19

(Code previously proposed and reviewed in #26, so will look familiar logic to some.)

Side note. multiples does not make the values start with an empty array because:

  • we don't do defaults for other options
  • an empty array would make detecting whether the option has been used different for a multiple

@Eomm Eomm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not find a test case using multiple and a single value. Do you think it is worth adding it?

Other than that LGTM

@shadowspawn

Copy link
Copy Markdown
Collaborator Author

Good suggestion, thanks @Eomm. Will do.

@bcoe
bcoe merged commit c357584 into pkgjs:main Jan 23, 2022
@shadowspawn
shadowspawn deleted the feature/fix-arrays branch January 23, 2022 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants