Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions roborock/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ def cli(ctx, debug: int):

@click.command()
@click.option("--email", required=True)
@click.option("--password", required=True)
@click.option(
"--password",
required=False,
help="Password for the Roborock account. If not provided, an email code will be requested.",
)
@click.pass_context
@run_sync()
async def login(ctx, email, password):
Expand All @@ -75,7 +79,14 @@ async def login(ctx, email, password):
except RoborockException:
pass
client = RoborockApiClient(email)
user_data = await client.pass_login(password)
if password is not None:
user_data = await client.pass_login(password)
else:
print(f"Requesting code for {email}")
await client.request_code()
code = click.prompt("A code has been sent to your email, please enter the code", type=str)
user_data = await client.code_login(code)
print("Login successful")
context.update(LoginData(user_data=user_data, email=email))


Expand Down