Skip to content

Commit e1a9e69

Browse files
authored
feat: Update CLI to allow logging in with a code (#395)
1 parent b19dbaa commit e1a9e69

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

roborock/cli.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ def cli(ctx, debug: int):
6262

6363
@click.command()
6464
@click.option("--email", required=True)
65-
@click.option("--password", required=True)
65+
@click.option(
66+
"--password",
67+
required=False,
68+
help="Password for the Roborock account. If not provided, an email code will be requested.",
69+
)
6670
@click.pass_context
6771
@run_sync()
6872
async def login(ctx, email, password):
@@ -75,7 +79,14 @@ async def login(ctx, email, password):
7579
except RoborockException:
7680
pass
7781
client = RoborockApiClient(email)
78-
user_data = await client.pass_login(password)
82+
if password is not None:
83+
user_data = await client.pass_login(password)
84+
else:
85+
print(f"Requesting code for {email}")
86+
await client.request_code()
87+
code = click.prompt("A code has been sent to your email, please enter the code", type=str)
88+
user_data = await client.code_login(code)
89+
print("Login successful")
7990
context.update(LoginData(user_data=user_data, email=email))
8091

8192

0 commit comments

Comments
 (0)