Skip to content

Commit

Permalink
feat/add --headless to --help (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
SafetyQuincyF authored Nov 18, 2024
1 parent 365ba04 commit 223ad60
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@
],
"console": "integratedTerminal"
},
{
"name": "Safety --help",
"type": "debugpy",
"request": "launch",
"module": "safety",
"args": [
"--help"
],
"console": "integratedTerminal"
},
{
"name": "Run All Tests",
"type": "debugpy",
Expand Down
14 changes: 12 additions & 2 deletions safety/auth/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from ..cli_util import get_command_for, pass_safety_cli_obj, SafetyCLISubGroup

from .constants import MSG_FAIL_LOGIN_AUTHED, MSG_FAIL_REGISTER_AUTHED, MSG_LOGOUT_DONE, MSG_LOGOUT_FAILED, MSG_NON_AUTHENTICATED
from safety.scan.constants import CLI_AUTH_COMMAND_HELP, DEFAULT_EPILOG, CLI_AUTH_LOGIN_HELP, CLI_AUTH_LOGOUT_HELP, CLI_AUTH_STATUS_HELP
from safety.scan.constants import CLI_AUTH_COMMAND_HELP, CLI_AUTH_HEADLESS_HELP, DEFAULT_EPILOG, CLI_AUTH_LOGIN_HELP, CLI_AUTH_LOGOUT_HELP, CLI_AUTH_STATUS_HELP


from rich.padding import Padding
Expand Down Expand Up @@ -124,7 +124,17 @@ def render_successful_login(auth: Auth,


@auth_app.command(name=CMD_LOGIN_NAME, help=CLI_AUTH_LOGIN_HELP)
def login(ctx: typer.Context, headless: bool = False) -> None:
def login(
ctx: typer.Context,
headless: Annotated[
Optional[bool],
typer.Option(
"--headless",
help=CLI_AUTH_HEADLESS_HELP,
)
] = None
) -> None:
headless = headless is True
"""
Authenticate Safety CLI with your safetycli.com account using your default browser.
Expand Down
13 changes: 10 additions & 3 deletions safety/scan/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@
f"Documentation: {CLI_DOCUMENTATION_URL}\n"\
f"Contact: {CLI_SUPPORT_EMAIL}\n"

CLI_AUTH_COMMAND_HELP = "Authenticate Safety CLI to perform scans. Your default browser will automatically open to https://platform.safetycli.com."\
"\nExample: safety auth login"
CLI_AUTH_COMMAND_HELP = (
"Authenticate Safety CLI to perform scans. Your default browser will automatically open to "
"https://platform.safetycli.com.\n\n"
"Example:\n safety auth login\n\n"
"For headless authentication, you will receive a URL to paste into an external browser.\n\n"
"Example:\n safety auth login --headless"
)

CLI_AUTH_HEADLESS_HELP = "For headless authentication, you will receive a URL to paste into an external browser."

CLI_SCAN_COMMAND_HELP = "Scans a Python project directory."\
"\nExample: safety scan to scan the current directory"
CLI_SYSTEM_SCAN_COMMAND_HELP = "\\[beta] Run a comprehensive scan for packages and vulnerabilities across your entire machine/environment."\
Expand Down Expand Up @@ -72,7 +80,6 @@
CLI_DISABLE_OPTIONAL_TELEMETRY_DATA_HELP = "Opt-out of sending optional telemetry data. Anonymized telemetry data will remain.\n\n" \
"[bold]Example: safety --disable-optional-telemetry scan[/bold]"


# Scan Help options
SCAN_POLICY_FILE_HELP = "Use a local policy file to configure the scan.\n\n" \
"[nhc]Note: Project scan policies defined in Safety Platform will override local policy files[/nhc]\n\n" \
Expand Down

0 comments on commit 223ad60

Please sign in to comment.