mirror of
https://github.com/ihabunek/toot.git
synced 2025-02-02 15:07:51 -05:00
Allow passing instance and email to login command
This commit is contained in:
parent
65da61b8b6
commit
fff5c8bc98
@ -1,6 +1,10 @@
|
||||
Changelog
|
||||
---------
|
||||
|
||||
**0.13.0 (TBA)**
|
||||
|
||||
* Allow passing `--instance` and `--email` to login command
|
||||
|
||||
**0.12.0 (2016-05-08)**
|
||||
|
||||
* Add option to disable ANSI color in output (#15)
|
||||
|
@ -35,25 +35,27 @@ def register_app(instance):
|
||||
return app
|
||||
|
||||
|
||||
def create_app_interactive():
|
||||
print_out("Choose an instance [<green>{}</green>]: ".format(DEFAULT_INSTANCE), end="")
|
||||
|
||||
instance = input()
|
||||
def create_app_interactive(instance=None):
|
||||
if not instance:
|
||||
instance = DEFAULT_INSTANCE
|
||||
print_out("Choose an instance [<green>{}</green>]: ".format(DEFAULT_INSTANCE), end="")
|
||||
instance = input()
|
||||
if not instance:
|
||||
instance = DEFAULT_INSTANCE
|
||||
|
||||
return config.load_app(instance) or register_app(instance)
|
||||
|
||||
|
||||
def login_interactive(app):
|
||||
print_out("\nLog in to <green>{}</green>".format(app.instance))
|
||||
def login_interactive(app, email=None):
|
||||
print_out("Log in to <green>{}</green>".format(app.instance))
|
||||
|
||||
if email:
|
||||
print_out("Email: <green>{}</green>".format(email))
|
||||
|
||||
while not email:
|
||||
email = input('Email: ')
|
||||
|
||||
email = input('Email: ')
|
||||
password = getpass('Password: ')
|
||||
|
||||
if not email or not password:
|
||||
raise ConsoleError("Email and password cannot be empty.")
|
||||
|
||||
try:
|
||||
print_out("Authenticating...")
|
||||
response = api.login(app, email, password)
|
||||
@ -199,8 +201,8 @@ def auth(app, user, args):
|
||||
|
||||
|
||||
def login(app, user, args):
|
||||
app = create_app_interactive()
|
||||
login_interactive(app)
|
||||
app = create_app_interactive(instance=args.instance)
|
||||
login_interactive(app, args.email)
|
||||
|
||||
print_out()
|
||||
print_out("<green>✓ Successfully logged in.</green>")
|
||||
|
@ -43,7 +43,16 @@ AUTH_COMMANDS = [
|
||||
Command(
|
||||
name="login",
|
||||
description="Log into a Mastodon instance",
|
||||
arguments=[],
|
||||
arguments=[
|
||||
(["-i", "--instance"], {
|
||||
"type": str,
|
||||
"help": 'mastodon instance to log into e.g. "mastodon.social"',
|
||||
}),
|
||||
(["-e", "--email"], {
|
||||
"type": str,
|
||||
"help": 'email address to log in with',
|
||||
}),
|
||||
],
|
||||
require_auth=False,
|
||||
),
|
||||
Command(
|
||||
|
Loading…
Reference in New Issue
Block a user