Repository: ErikBjare/gptme
File: gptme/server/cli.py (Python)

Code before:
        shutdown_telemetry()


@main.command("token")
def show_token():
    """Display the server authentication token."""
    token = get_server_token()
    if token:
        click.echo("=" * 60)
        click.echo("gptme-server Authentication Token")
        click.echo("=" * 60)
        click.echo(f"Token: {token}")
        click.echo("")
        click.echo("Use this token in the Authorization header:")
        click.echo(f"  Authorization: Bearer {token}")
        click.echo("=" * 60)
    else:
        click.echo("=" * 60)
        click.echo("gptme-server Authentication")
        click.echo("=" * 60)
        click.echo("Authentication is DISABLED (no token configured)")
        click.echo("")
        click.echo(
            "To enable authentication, set the GPTME_SERVER_TOKEN environment variable:"
        )
        click.echo("  GPTME_SERVER_TOKEN=your-secret-token gptme server serve")
        click.echo("=" * 60)


@main.command("openapi")
@click.option("-o", "--output", default="openapi.json", help="Output file path")
def generate_openapi(output: str):
    """Generate OpenAPI specification without starting server."""
    app = create_app()
    with app.app_context():
        from .openapi_docs import generate_openapi_spec

        spec = generate_openapi_spec()

        with open(output, "w") as f:
            json.dump(spec, f, indent=2)

        click.echo(f"OpenAPI specification generated: {output}")


if __name__ == "__main__":
    main()


Review comment (security):
```suggestion
        click.echo("  GPTME_SERVER_TOKEN=your-secret-token gptme-server serve")
```

All of these `gptme server serve` and `gptme server ...` need to be `gptme-server serve` or similar since the former would just run `gptme` with the prompt `server serve`. Needs to be fixed all across the PR.

Code after:
        shutdown_telemetry()


@main.command("token")
def show_token():
    """Display the server authentication token."""
    token = get_server_token()
    if token:
        click.echo("=" * 60)
        click.echo("gptme-server Authentication Token")
        click.echo("=" * 60)
        click.echo(f"Token: {token}")
        click.echo("")
        click.echo("Use this token in the Authorization header:")
        click.echo(f"  Authorization: Bearer {token}")
        click.echo("=" * 60)
    else:
        click.echo("=" * 60)
        click.echo("gptme-server Authentication")
        click.echo("=" * 60)
        click.echo("Authentication is DISABLED (no token configured)")
        click.echo("")
        click.echo(
            "To enable authentication, set the GPTME_SERVER_TOKEN environment variable:"
        )
        click.echo("  GPTME_SERVER_TOKEN=your-secret-token gptme-server serve")
        click.echo("=" * 60)


@main.command("openapi")
@click.option("-o", "--output", default="openapi.json", help="Output file path")
def generate_openapi(output: str):
    """Generate OpenAPI specification without starting server."""
    app = create_app()
    with app.app_context():
        from .openapi_docs import generate_openapi_spec

        spec = generate_openapi_spec()

        with open(output, "w") as f:
            json.dump(spec, f, indent=2)

        click.echo(f"OpenAPI specification generated: {output}")


if __name__ == "__main__":
    main()