Skip to content

Commit 8cb0667

Browse files
committed
refactor: replace --gateway flag with --asgi boolean flag
Simplify the CLI by replacing `--gateway asgi` with `--asgi`. The new flag is more intuitive as WSGI remains the default and ASGI is opt-in. Also updates the environment variable to FUNCTION_USE_ASGI for clarity.
1 parent a576a8f commit 8cb0667

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/functions_framework/_cli.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@
3333
@click.option("--port", envvar="PORT", type=click.INT, default=8080)
3434
@click.option("--debug", envvar="DEBUG", is_flag=True)
3535
@click.option(
36-
"--gateway",
37-
envvar="FUNCTION_GATEWAY",
38-
type=click.Choice(["wsgi", "asgi"]),
39-
default="wsgi",
40-
help="Server gateway interface type (wsgi for sync, asgi for async)",
36+
"--asgi",
37+
envvar="FUNCTION_USE_ASGI",
38+
is_flag=True,
39+
help="Use ASGI server for function execution",
4140
)
42-
def _cli(target, source, signature_type, host, port, debug, gateway):
43-
if gateway == "asgi": # pragma: no cover
41+
def _cli(target, source, signature_type, host, port, debug, asgi):
42+
if asgi: # pragma: no cover
4443
from functions_framework.aio import create_asgi_app
4544

4645
app = create_asgi_app(target, source, signature_type)

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def test_asgi_cli(monkeypatch):
119119
monkeypatch.setattr(functions_framework._cli, "create_server", create_server)
120120

121121
runner = CliRunner()
122-
result = runner.invoke(_cli, ["--target", "foo", "--gateway", "asgi"])
122+
result = runner.invoke(_cli, ["--target", "foo", "--asgi"])
123123

124124
assert result.exit_code == 0
125125
assert create_asgi_app.calls == [pretend.call("foo", None, "http")]

0 commit comments

Comments
 (0)