Introduction
Introduction Statistics Contact Development Disclaimer Help
Allow passing instance and email to login command - toot - Unnamed repository; …
Log
Files
Refs
LICENSE
---
commit fff5c8bc98b51c093ccd332d41a90c2e5bfbd82f
parent 65da61b8b6808dd94b6e30e026452d2d9878a3f7
Author: Ivan Habunek <[email protected]>
Date: Sat, 26 Aug 2017 11:33:36 +0200
Allow passing instance and email to login command
Diffstat:
CHANGELOG.md | 4 ++++
toot/commands.py | 28 +++++++++++++++-------------
toot/console.py | 11 ++++++++++-
3 files changed, 29 insertions(+), 14 deletions(-)
---
diff --git 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
@@ -35,24 +35,26 @@ def register_app(instance):
return app
-def create_app_interactive():
- print_out("Choose an instance [<green>{}</green>]: ".format(DEFAULT_INSTAN…
-
- instance = input()
+def create_app_interactive(instance=None):
if not instance:
- instance = DEFAULT_INSTANCE
+ print_out("Choose an instance [<green>{}</green>]: ".format(DEFAULT_IN…
+ 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))
- email = input('Email: ')
- password = getpass('Password: ')
+ if email:
+ print_out("Email: <green>{}</green>".format(email))
- if not email or not password:
- raise ConsoleError("Email and password cannot be empty.")
+ while not email:
+ email = input('Email: ')
+
+ password = getpass('Password: ')
try:
print_out("Authenticating...")
@@ -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>")
diff --git 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(
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.