20 lines
493 B
Python
20 lines
493 B
Python
import click
|
|
|
|
import api.me
|
|
from config import Config
|
|
from .cli import cli
|
|
|
|
|
|
@cli.command('login')
|
|
@click.option('--email', prompt=True)
|
|
@click.option('--password', prompt=True, hide_input=True)
|
|
def login(email: str, password: str) -> None:
|
|
user = api.me.get(email, password)
|
|
|
|
print()
|
|
print(f"Logged in successfully as {user['name']} (@{user['username']}).")
|
|
|
|
Config['user']['api_token'] = user['api_token']
|
|
Config['user']['initials'] = user['initials']
|
|
Config.write()
|