drizzle-team / drizzle-team/brocli

feature request: repeated parameters

Open
#3 0 comments 1 reaction 1 assignee Claimed by @Sukairo-02 View on GitHub
Dominant language
TypeScript
Stars
477
Forks
6
PR merge metrics
No merged PRs in 30d

Description

it often makes sense to have the same argument repeated multiple times (both named and positional)

e.g. with [arg](//npm.im/arg) it's possible to do something like this:

```ts
const args = arg({
'--foo': [String]
} as const, { permissive: true })

console.log(args)
```

which would result in something like this:

```
$ node test.js --foo=1 --foo=2 1 2 3 4
{
_: ['1', '2', '3', '4'],
'--foo': ['1', '2'],
}
```

this is currently not possible with brocli however :c
the best workaround currently is to use e.g. comma delimiter and manually split them, which is obviously not ideal – you have to account for the comma being a part of one of the items, and it also looks awkward as positional args

my proposed api would look something like this:

```ts
const foo = command({
name: 'foo',
options: {
foo: string().repeated(),
bar: positional().repeated()
},
handler: console.log
})
```

which would print a similar output to the above

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.