summaryrefslogtreecommitdiff
path: root/archivist/utils.py
blob: 391a8fb86d992760893614aca580c03f61f6eec2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from click import MultiCommand

class ProxyCommand(MultiCommand):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.__proxy = None

    def _get_proxy(self):
        raise NotImplementedError("_get_proxy")

    def __load(self):
        if self.__proxy is None:
            self.__proxy = self._get_proxy()

    def list_commands(self,ctx):
        self.__load()
        return self.__proxy.list_commands(ctx)

    def get_command(self,ctx,name):
        self.__load()
        return self.__proxy.get_command(ctx,name)

    def make_context(self, *args, **kwargs):
        self.__load()
        return self.__proxy.make_context(*args, **kwargs)