majuna/app/cli/__init__.py

23 lines
572 B
Python
Raw Normal View History

2022-06-17 13:21:35 +01:00
import argparse
from abc import abstractmethod
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
_SubparserType = argparse._SubParsersAction[argparse.ArgumentParser] # pylint: disable=protected-access
else:
_SubparserType = Any
class BaseCliHandler:
def __init__(self, args: argparse.Namespace) -> None:
self.args = args
@classmethod
@abstractmethod
def add_subparser_to(cls, subparsers: _SubparserType) -> None:
raise NotImplementedError
@abstractmethod
def run(self) -> None:
raise NotImplementedError