Lazy load cache command
MODIFY
plextraktsync/cli.py
plextraktsync/cli.py
from functools import wraps
import click
-from plextraktsync.commands.cache import cache
from plextraktsync.commands.clear_collections import clear_collections
from plextraktsync.commands.info import info
from plextraktsync.commands.inspect import inspect
@@ -45,6 +44,33 @@ def cli(ctx):
sync()
+@command()
+@click.option(
+ "--sort",
+ type=click.Choice(["size", "date", "url"], case_sensitive=False),
+ default="size",
+ show_default=True, help="Sort mode"
+)
+@click.option(
+ "--limit",
+ type=int,
+ default=20,
+ show_default=True, help="Limit entries to be printed"
+)
+@click.option(
+ "--reverse",
+ is_flag=True,
+ default=False,
+ help="Sort reverse"
+)
+@click.argument("url", required=False)
+def cache():
+ """
+ Manage and analyze Requests Cache.
+ """
+ pass
+
+
cli.add_command(cache)
cli.add_command(clear_collections)
cli.add_command(info)

MODIFY
plextraktsync/commands/cache.py
plextraktsync/commands/cache.py
@@ -70,31 +70,7 @@ def inspect_url(session: CachedSession, url: str):
print(m.content)
-@click.command()
-@click.option(
- "--sort",
- type=click.Choice(["size", "date", "url"], case_sensitive=False),
- default="size",
- show_default=True, help="Sort mode"
-)
-@click.option(
- "--limit",
- type=int,
- default=20,
- show_default=True, help="Limit entries to be printed"
-)
-@click.option(
- "--reverse",
- is_flag=True,
- default=False,
- help="Sort reverse"
-)
-@click.argument("url", required=False)
def cache(sort: str, limit: int, reverse: bool, url: str):
- """
- Manage and analyze Requests Cache.
- """
-
config = factory.config()
trakt_cache = config["cache"]["path"]
session = CachedSession(cache_name=trakt_cache, backend='sqlite')

Lazy load cache command