diff options
Diffstat (limited to '')
| -rw-r--r-- | webmentions_ssg/cli.py | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/webmentions_ssg/cli.py b/webmentions_ssg/cli.py index 0387ba6..0fed7dd 100644 --- a/webmentions_ssg/cli.py +++ b/webmentions_ssg/cli.py @@ -22,7 +22,6 @@ USERS_CLI = AppGroup("users", help="Manage users.") def _require_user(username: str): """Return a user by username or report a CLI-friendly error.""" - user = DATABASE.session.scalar(sa.select(User).where(User.username == username)) if user is None: raise click.ClickException(f"User {username!r} does not exist.") @@ -33,14 +32,12 @@ def _require_user(username: str): @click.option("--username", prompt="Username", help="Username for the new user.") @click.password_option(confirmation_prompt=True) def create_user(username: str, password: str) -> None: - """ - Create a user with a securely hashed password. + """Create a user with a securely hashed password. :param username: Username for the new user. :param password: Plain-text password to hash and store. :raises click.ClickException: If the credentials are invalid or the user exists. """ - username = username.strip() if not username: raise click.ClickException("Username must not be empty.") @@ -66,7 +63,6 @@ def create_user(username: str, password: str) -> None: @USERS_CLI.command("list", help="List registered users.") def list_users() -> None: """List user IDs and usernames in alphabetical order.""" - users = DATABASE.session.scalars(sa.select(User).order_by(User.username)).all() if not users: click.echo("No users found.") @@ -81,8 +77,7 @@ def list_users() -> None: @click.argument("username") @click.password_option(confirmation_prompt=True) def set_user_password(username: str, password: str) -> None: - """ - Change a user's password without displaying it. + """Change a user's password without displaying it. :param username: Username of the account to update. :param password: New plain-text password to hash and store. @@ -103,8 +98,7 @@ def set_user_password(username: str, password: str) -> None: @click.argument("username") @click.option("-y", "--yes", is_flag=True, help="Skip the deletion confirmation.") def delete_user(username: str, yes: bool) -> None: - """ - Permanently delete a user after confirmation, unless --yes is passed. + """Permanently delete a user after confirmation, unless --yes is passed. :param username: Username of the account to remove. :param yes: Whether to skip the confirmation prompt. @@ -127,8 +121,7 @@ MAIL_CLI = AppGroup("mail", help="Handle mail") "--to", "recipient", help="Recipient address (defaults to NOTIFICATION_EMAIL)." ) def send_test_mail(recipient: str | None) -> None: - """ - Send a test email using the configured SMTP server. + """Send a test email using the configured SMTP server. :param recipient: Optional recipient overriding NOTIFICATION_EMAIL. :raises click.ClickException: If configuration is missing or sending fails. |
