pyapp-org/pyapp

Extend @app.command to accept sequence of enums in comand line options

Closed this issue · 0 comments

I would like to define a cli command with the following signature

`class FooEnum(Enum):
"""
Foo definitions
"""

Fe = "Fe"
Fi = "Fi"
Fo = "Fo"

class BarEnum(Enum):
"""
Foo definitions
"""

Be = "Be"
Bi = "Bi"
Bo = "Bo"

@app.command()
def create(
foo: FooEnum = Arg(help="All about the foo"),
*,
bar: Sequence[BarEnum] = Arg(
"-b", default=None, help="List of optional bars"
),
) -> Optional[int]:`

So that I can call it on the command line with the following arguments

$ myapp create Fe --bar Be Bi

or with

$ myapp create Fe --bar Be --bar Bi