Add login command to log in if needed
MODIFY
plex_trakt_sync/cli.py
plex_trakt_sync/cli.py
from plex_trakt_sync.commands.cache import cache
from plex_trakt_sync.commands.clear_collections import clear_collections
from plex_trakt_sync.commands.inspect import inspect
+from plex_trakt_sync.commands.login import login
from plex_trakt_sync.commands.plex_login import plex_login, has_plex_token
from plex_trakt_sync.commands.sync import sync
from plex_trakt_sync.commands.trakt_login import trakt_login, has_trakt_token
@@ -27,6 +28,7 @@ def cli(ctx):
cli.add_command(cache)
cli.add_command(clear_collections)
cli.add_command(inspect)
+cli.add_command(login)
cli.add_command(plex_login)
cli.add_command(sync)
cli.add_command(trakt_login)

ADD
plex_trakt_sync/commands/login.py
+import click
+
+from plex_trakt_sync.commands.plex_login import has_plex_token, plex_login
+from plex_trakt_sync.commands.trakt_login import has_trakt_token, trakt_login
+
+
+@click.command()
+def login():
+ """
+ Log in to Plex and Trakt if needed
+ """
+ if not has_plex_token():
+ plex_login()
+ if not has_trakt_token():
+ trakt_login()

Add login command to log in if needed