dockge-cli/dockge_cli/client/commandprovider/factory.py

18 lines
434 B
Python
Raw Normal View History

from typing import List, Callable
from pydantic import BaseModel
from .descriptors import command_mappings
class Command(BaseModel):
command: str
description: str
args: int
optional: bool
binding: Callable
commands: dict[str, Command] = {}
descriptors: List[dict[str, object]] = command_mappings
for descriptor in descriptors:
c = Command(**descriptor) # type: ignore
commands.update({ c.command: c })