Skip to content

Prepared annotations

CLI flags have no effect in the UI. Great for CLI so that the user writes less.

mininterface.tag.flag.Blank

When left blank, this flag produces True. Return boolean for True|False. Return None if the flag is omitted. Else returns T created from the input value.

Note that you can not use 'True' or 'False' for values, as the parameter becomes a bool.

Warning

Experimental.

mininterface.tag.flag.BlankTrue = Annotated[list[str] | None, PrimitiveConstructorSpec(nargs='*', metavar='blank=True|BOOL', instance_from_str=_assure_blank_or_bool, is_instance=lambda instance: True, str_from_instance=lambda instance: [instance])]

When left blank, this flag produces True.

Returns:

Name Type Description
bool

for 0/false/off/1/true/on in the parameter

True

When parameter is left blank.

Raises:

Type Description
ValueError

Raised on an unknown parameter.

Warning

Experimental.

mininterface.tag.flag.Dir = Annotated[Path, PathTag(is_dir=True)]

An existing directory. from mininterface import run from mininterface.tag.flag import Dir

@dataclass
class Env:
    my_dir: Dir

m = run(Env)
m.env.my_dir  # guaranteed to be an existing dir

Warning

EXPERIMENTAL.

mininterface.tag.flag.File = Annotated[Path, PathTag(is_file=True)]

An existing file. from mininterface import run from mininterface.tag.flag import File

@dataclass
class Env:
    my_file: File

m = run(Env)
m.env.my_file  # guaranteed to be an existing dir

Warning

EXPERIMENTAL.