minimistjs / minimist

parse argument options
MIT License
515 stars 30 forks source link

[New] Support for arrays in dotted notation (`--a[1].b`) #68

Closed git-developer closed 1 month ago

git-developer commented 1 month ago

I'd like to suggest a feature that seems to be missing: Support for arrays in dotted notation.

Let me explain the feature request using this simple example:

$ echo "console.log(require('minimist')(['--foo[0].bar=x', '--foo[2].bar=42']))" | node

Actual behavior

{ _: [], 'foo[0]': { bar: 'x' }, 'foo[2]': { bar: 42 } }

Desired behavior

{ _: [], foo: [ { bar: 'x' }, <1 empty item>, { bar: 42 } ] }

Motivation

66 is a request for the same feature using a different syntax foo.0.bar. That syntax may be used to reference an array and may be implemented using a one-liner, but is unusual. This PR adapts to the well-known square bracket syntax and allows to discuss each idea on its own.

git-developer commented 1 month ago

Closed due to comment.