Add ensure_login method without click decorator
This solves the problem that adding `click` decorator changed the
behavior of the method.
When the first problem of click calling `sys.exit` was fixed with
`standalone=False`, then next problem is that options are passed to the
wrong command, i.e to `login` command, not to `sync` command.
from plex_trakt_sync.commands.trakt_login import has_trakt_token, trakt_login
+def ensure_login():
+ if not has_plex_token():
+ plex_login()
+ if not 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()
+ ensure_login()
