(self, command: str, args: list[str])
| 36 | self.parser = self._make_parser() |
| 37 | |
| 38 | def run(self, command: str, args: list[str]) -> None: |
| 39 | if command == "exec": |
| 40 | args = ["--help"] |
| 41 | parsed_args = self.parser.parse_args(args) |
| 42 | if command not in self.commands: |
| 43 | raise ValueError(f"Unknown command: {command}") |
| 44 | parsed_kwargs = vars(parsed_args) |
| 45 | parsed_kwargs.pop("command") |
| 46 | run(self.commands[command](**parsed_kwargs)) |
| 47 | |
| 48 | def _make_commands(self) -> dict[str, Callable]: |
| 49 | commands = {c.name: c.func for c in self.app._future_commands} |