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
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
Baber's avatar
cleanup  
Baber committed
17
    def _add_args(self) -> None:
Baber's avatar
Baber committed
18
19
        """Add arguments specific to this subcommand."""
        pass