edornd / argdantic

Typed command line interfaces with argparse and pydantic
MIT License
38 stars 4 forks source link

Support for mutually exclusive groups #50

Open fennerm opened 4 months ago

fennerm commented 4 months ago

Describe the solution you'd like It would be nice if argparse's mutually exclusive argument groups could be supported. If arguments are placed in a mutually exclusive group, the help message should indicate them by listing as --option_a | --option_b | .... Argdantic should verify that at least one of the arguments in the group was passed.

Describe alternatives you've considered Currently we can handle by adding extra verification in the main func, but the help message is not so clear

edornd commented 3 weeks ago

Hi @fennerm, this is already done by booleans, but it sounds indeed as something that could be more "general purpose". In short, it is definitely feasible, I just don't have a clear (and clean) idea on how to define a group in practice, when defining the arguments 🤔 pydantic itself has no built-in way to define them, [either than provide a validator ].(https://github.com/pydantic/pydantic/issues/522#issuecomment-829491002)