def create_user(
    username: str, password: str, admin: bool = False, api_key: str | None = None
) -> None:
    """Creates a new user in the system."""
    user = UserSensitive.find(username=username)
    if user:
        raise RuntimeError(f"User with username {username} already exists")
    user = UserSensitive(username=username, admin=admin)
    user.set_password(password)
    if api_key:
        user.reset_api_key(api_key=api_key)
    user.save()
    token = user.create_api_key("default")
    click.echo(f"User {username} succesfully created! API key: {username}:{token}")
Creates a new user in the system.
yetictl/cli.py