subcommand.py 480 Bytes
Newer Older
Baber's avatar
Baber committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import argparse
from abc import ABC, abstractmethod


class SubCommand(ABC):
    """Base class for all subcommands."""

    def __init__(self, *args, **kwargs):
        pass

    @classmethod
    def create(cls, subparsers: argparse._SubParsersAction):
        """Factory method to create and register a command instance."""
        return cls(subparsers)

    @abstractmethod
    def _add_args(self) -> None:
        """Add arguments specific to this subcommand."""
        pass