~brenns10/subc

cc544f0f779e2e91c4b5b0ba79fba678bfaaeaca — Stephen Brennan 2 years ago eb843d3
Add type annotations
1 files changed, 6 insertions(+), 0 deletions(-)

M subc.py
M subc.py => subc.py +6 -0
@@ 36,25 36,31 @@ class Command(ABC):

    @abstractproperty
    def name(self):
        # type: () -> str
        pass

    @abstractproperty
    def description(self):
        # type: () -> str
        pass

    def add_args(self, parser):
        # type: (argparse.ArgumentParser) -> None
        pass  # default is no arguments

    @abstractmethod
    def run(self):
        # type: () -> None
        pass

    def base_run(self, args):
        # type: (argparse.Namespace) -> None
        self.args = args
        return self.run()

    @classmethod
    def add_commands(cls, parser):
        # type: (argparse.ArgumentParser) -> None
        subparsers = parser.add_subparsers(title='sub-command')
        for subcls in cls.__subclasses__():
            cmd = subcls()