-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathauth_command.py
More file actions
28 lines (21 loc) · 867 Bytes
/
auth_command.py
File metadata and controls
28 lines (21 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import typer
from cycode.cli.apps.auth.auth_manager import AuthManager
from cycode.cli.exceptions.handle_auth_errors import handle_auth_exception
from cycode.cli.logger import logger
from cycode.cli.models import CliResult
from cycode.cli.utils.sentry import add_breadcrumb
def auth_command(ctx: typer.Context) -> None:
"""Authenticates your machine."""
add_breadcrumb('auth')
printer = ctx.obj.get('console_printer')
if ctx.invoked_subcommand is not None:
# if it is a subcommand, do nothing
return
try:
logger.debug('Starting authentication process')
auth_manager = AuthManager()
auth_manager.authenticate()
result = CliResult(success=True, message='Successfully logged into cycode')
printer.print_result(result)
except Exception as err:
handle_auth_exception(ctx, err)