summaryrefslogtreecommitdiff
path: root/archivist/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'archivist/utils.py')
-rw-r--r--archivist/utils.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/archivist/utils.py b/archivist/utils.py
new file mode 100644
index 0000000..391a8fb
--- /dev/null
+++ b/archivist/utils.py
@@ -0,0 +1,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)