Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: repeated parameters #3

Open
teidesu opened this issue Oct 30, 2024 · 0 comments
Open

feature request: repeated parameters #3

teidesu opened this issue Oct 30, 2024 · 0 comments
Assignees

Comments

@teidesu
Copy link

teidesu commented Oct 30, 2024

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

e.g. with arg it's possible to do something like this:

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:

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

which would print a similar output to the above

@Sukairo-02 Sukairo-02 self-assigned this Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants