Validate arguments passed to "login" command

This commit is contained in:
Andrew Ferrazzutti 2022-05-09 03:18:33 -04:00
parent d594fb98d1
commit b8b451b751

View File

@ -69,8 +69,13 @@ async def login(evt: CommandEvent) -> None:
await evt.reply("You're already logged in")
return
save = len(evt.args) > 0 and evt.args[0] == "--save"
email = evt.args[0 if not save else 1] if len(evt.args) > 0 else None
num_args = len(evt.args)
save = num_args > 0 and evt.args[0] == "--save"
# TODO Once web login is implemented, don't make <email> a mandatory argument
if not save and num_args != 1:
await evt.reply("**Usage:** `$cmdprefix+sp login [--save] <email>`")
return
email = evt.args[0 if not save else 1] if num_args > 0 else None
if email:
evt.sender.command_status = {