-
-
Notifications
You must be signed in to change notification settings - Fork 836
Open
Labels
Description
Is your feature request related to a problem
I would like to be able to unleash the power of Enum ! The first case I stumbled onto is that of logging, e.g have the following Enum usable in typer:
class LogLevel(Enum):
debug = 10
info = 20
warning = 30Instead I have to use this one, and then convert the string to the right value
class LogLevel(Enum):
debug = "debug"
info = "info"
warning = "warning"The solution you would like
I would like typer to interpret the value.name as arguments, and provide value.value to the called function, so that the following program would work as intended:
from enum import Enum
import typer
import logging
logger = logging.getLogger(__name__)
class LogLevel(Enum):
debug = logging.DEBUG
info = logging.INFO
warning = logging.WARNING
def main(
level: LogLevel,
):
logger.setLevel(level)
...
if __name__ == "__main__":
typer.run(main)Reactions are currently unavailable