lua_cliargs icon indicating copy to clipboard operation
lua_cliargs copied to clipboard

Drop arbitrary limit on splat arguments

Open n0la opened this issue 9 years ago • 5 comments

What is the deal with a numeric limit on splat() arguments? Why not just specify unlimited by default? If anyone wants to limit it to 1 he could always optionally pass that integer. But a limit between 1 and 999 seems quite arbitrary to me.

n0la avatar Nov 30 '16 13:11 n0la

That's a good question. I don't recall the details, so I have to look at the sources again. Is the limit causing an issue for you?

Maybe @Tieske could shed some light if he still remembers as I believe he introduced it in the first place.

amireh avatar Dec 09 '16 09:12 amireh

Not directly an issue but it's weird and counter intuitive API behaviour.

If I do a command like:

# takes a list of items and calculates the price of each
myproject calc "item 1" "item 2" "item3"

I expect that:

cli:splat("ITEMS", "list of items for which to calculate the price")
-- and not:
-- cli:splat("ITEMS", "list of items for which to calculate the price", nil, 999)

is enough to allow a list of multiple items. If there were just one item I would not be using splat() in the first place, but rather use option.

n0la avatar Dec 09 '16 15:12 n0la

I don't recall why, probably has to do with implementation details. First thing that comes to mind is formatting error messages.

But from a functional perspective I don't see why this could not be changed.

Tieske avatar Dec 19 '16 13:12 Tieske

I studied the code, and the maximum amount is also used to determine if enough parameters have been given on the command line; with 0 options being a valid amount.

n0la avatar Dec 19 '16 14:12 n0la

Hey @n0la, I've spent some time going over the splat argument logic and dropped the arbitrary limit of 999 and made the default behaviour to accept an unlimited number of repetitions. Since that's a breaking API change, we must do it in a major release.

Please check it out if you can so that can proceed.

amireh avatar Jan 14 '17 14:01 amireh