Add wrapper command to be able to lazy load commands
MODIFY
plextraktsync/cli.py
plextraktsync/cli.py
+from functools import wraps
import click
from plextraktsync.commands.cache import cache
from plextraktsync.commands.watch import watch
+def command():
+ """
+ Wrapper to lazy load commands when commands being executed only
+ """
+
+ def decorator(fn):
+ @click.command()
+ @wraps(fn)
+ def wrap(*args, **kwargs):
+ import importlib
+
+ name = fn.__name__
+ module = importlib.import_module(f'.commands.{name}', package=__package__)
+ cmd = getattr(module, name)
+ cmd(*args, **kwargs)
+
+ return wrap
+
+ return decorator
+
+
@click.group(invoke_without_command=True)
@click.pass_context
def cli(ctx):

Add wrapper command to be able to lazy load commands