click icon indicating copy to clipboard operation
click copied to clipboard

Opinion: Arguments should not be required for Variadics

Open Rowlando13 opened this issue 1 year ago • 1 comments

Docs:

  • Arguments: If you come from argparse, you might be missing support for setting nargs to + to indicate that at least one argument is required. This is supported by setting required=True. However, this should not be used if you can avoid it as we believe scripts should gracefully degrade into becoming noops if a variadic argument is empty. The reason for this is that very often, scripts are invoked with wildcard inputs from the command line and they should not error out if the wildcard is empty.

Reasoning: Beyond the reasoning stated, I don't know of any.

Feature unlocked: N/A

Rowlando13 avatar Dec 15 '24 06:12 Rowlando13

I don't think this one is a problem. As it says, the feature is already supported (nargs=-1, required=True). Stating why that might be a bad idea if you're trying to design a CLI tool that behaves well in pipelines seems fine to me.

davidism avatar Jun 19 '25 22:06 davidism