-
It seems that it's not possible to have CLI Options/Arguments that accept multiple types. For example, creating a CLI Option with a Union[] type so that I can refer to some item either by its numerical ID or its string name:
Doesn't work. Running this yields this error: As a work-around, is it possible to make two CLI Options, and indicate that only one of the two Options are required? For example, could you have an It's not obvious in the documentation if this is possible (or I just haven't read it thoroughly enough). Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is probably a question for Typer, not for Typer-CLI. And now Typer includes all the logic and Typer-CLI command, so everything should go there. Now, about your question, this functionality is provided by Click, so, as Click doesn't support more than one type, Typer can't do much about it. Maybe in the future I'll be able to optionally depend on Pydantic and extend the possibilities of what types are supported. But for now, it's not possible. 🥲 |
Beta Was this translation helpful? Give feedback.
This is probably a question for Typer, not for Typer-CLI. And now Typer includes all the logic and Typer-CLI command, so everything should go there.
Now, about your question, this functionality is provided by Click, so, as Click doesn't support more than one type, Typer can't do much about it. Maybe in the future I'll be able to optionally depend on Pydantic and extend the possibilities of what types are supported. But for now, it's not possible. 🥲