You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I guess you can already do this using the ArgumentParser from jsonargparse but I like CLI so much, it's really convenient otherwise, thanks again for the great library btw!
The text was updated successfully, but these errors were encountered:
Thank you for the proposal! I had thought about this a few times. Maybe I add it. The biggest issue is more complex cases and expectations from people. For example a type Optional[List[str]]. It would be problematic to have nargs='+' because --foo null ab should fail, but then it becomes quite complex to implement. And this is only one case out of many there could be.
As a side note, += is not the only way currently. A list can also be given like --foo="[ab,ac]". Still, not as convenient as a* would be.
I think it can make sense for both positional and non-positional. The issue that I meant is the following. Say someone has a function argument with type list[str] and the CLI gets created with nargs='+'. Then that person extends the code and the correct type becomes Union[list[str], int]. The int does not make sense with nargs='+' so what happens?
I see your point, with Union[list[str], int] the behavior should change to current behavior but that might be confusing to the user because then they cannot switch between e.g. a* and 42 but will need to use the current behavior "[ab,ac]".
I'm not sure I have a solution to that except letting the users know that nargs='+' only works with "pure" lists like list[str] but not Union[list[str], int] or Optional[List[str]]
🚀 Feature request
Motivation
Currently, to pass several arguments to a List, the syntax is quite difficult, you need to do something like
Pitch
A great thing about
argparse
is that you can addnargs='+'
so you can call it like
python jsonargparse_demo.py a*
and match all files starting with
"a"
Alternatives
I guess you can already do this using the ArgumentParser from jsonargparse but I like CLI so much, it's really convenient otherwise, thanks again for the great library btw!
The text was updated successfully, but these errors were encountered: