| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | import argparse |
| 5 | import typing |
| 6 | |
| 7 | if typing.TYPE_CHECKING: |
| 8 | from vllm.utils.argparse_utils import FlexibleArgumentParser |
| 9 | else: |
| 10 | FlexibleArgumentParser = argparse.ArgumentParser |
| 11 | |
| 12 | |
| 13 | class CLISubcommand: |
| 14 | """Base class for CLI argument handlers.""" |
| 15 | |
| 16 | name: str |
| 17 | |
| 18 | @staticmethod |
| 19 | def cmd(args: argparse.Namespace) -> None: |
| 20 | raise NotImplementedError("Subclasses should implement this method") |
| 21 | |
| 22 | def validate(self, args: argparse.Namespace) -> None: |
| 23 | # No validation by default |
| 24 | pass |
| 25 | |
| 26 | def subparser_init( |
| 27 | self, subparsers: argparse._SubParsersAction |
| 28 | ) -> FlexibleArgumentParser: |
| 29 | raise NotImplementedError("Subclasses should implement this method") |