diff --git a/CHANGELOG.md b/CHANGELOG.md
index cc6dea2..815e680 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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)
diff --git a/toot/commands.py b/toot/commands.py
index bb3edf2..9f953eb 100644
--- a/toot/commands.py
+++ b/toot/commands.py
@@ -35,25 +35,27 @@ def register_app(instance):
return app
-def create_app_interactive():
- print_out("Choose an instance [{}]: ".format(DEFAULT_INSTANCE), end="")
-
- instance = input()
+def create_app_interactive(instance=None):
if not instance:
- instance = DEFAULT_INSTANCE
+ print_out("Choose an instance [{}]: ".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 {}".format(app.instance))
+def login_interactive(app, email=None):
+ print_out("Log in to {}".format(app.instance))
+
+ if email:
+ print_out("Email: {}".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("✓ Successfully logged in.")
diff --git a/toot/console.py b/toot/console.py
index 3b22750..6034ca7 100644
--- a/toot/console.py
+++ b/toot/console.py
@@ -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(