Skip to content

Commit

Permalink
Adds --silent flag
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-russell committed Jul 30, 2024
1 parent c065f2c commit a30a99d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions fractal/cli/controllers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def login(
password: Optional[str] = None,
homeserver_url: Optional[str] = None,
access_token: Optional[str] = None,
silent: bool = False,
**kwargs,
):
"""
Expand All @@ -40,22 +41,27 @@ def login(
password: Password for the Matrix ID.
homeserver_url: Homeserver to login to.
access_token: Access token to use for login.
silent: Silently log in.
"""
if not access_token:
homeserver_url, access_token = async_to_sync(self._login_with_password)(
matrix_id, homeserver_url=homeserver_url, password=password
)
else:
if not homeserver_url:
print("Please provide a --homeserver-url if logging in with an access token.")
if not silent:
print(
"Please provide a --homeserver-url if logging in with an access token.",
file=sys.stderr,
)
exit(1)
try:
matrix_id, homeserver_url, access_token = async_to_sync(
self._login_with_access_token
)(access_token, homeserver_url=homeserver_url)
except MatrixLoginError as e:
print("Error logging in:", e)
if not silent:
print(f"Error logging in: {e}", file=sys.stderr)
exit(1)

# save access token to token file
Expand Down Expand Up @@ -89,7 +95,8 @@ def login(
homeserver=hs,
)

print(f"Successfully logged in as {matrix_id}")
if not silent:
print(f"Successfully logged in as {matrix_id}")

login.clicz_aliases = ["login"]

Expand Down

0 comments on commit a30a99d

Please sign in to comment.