diff --git a/.vscode/launch.json b/.vscode/launch.json index dd8477d8..8ce561ec 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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", diff --git a/safety/auth/cli.py b/safety/auth/cli.py index 8a0a2c1a..7320d12f 100644 --- a/safety/auth/cli.py +++ b/safety/auth/cli.py @@ -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 @@ -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. diff --git a/safety/scan/constants.py b/safety/scan/constants.py index f07b5aaa..7a9cf13b 100644 --- a/safety/scan/constants.py +++ b/safety/scan/constants.py @@ -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."\ @@ -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" \