Skip to content

Commit fda3bcd

Browse files
fix(cli): use callback pattern to avoid breaking no-subcommand invocation
Registering a second @app.command() forced Typer to require an explicit subcommand, breaking the existing `python -m webwright.run.cli -t "..."` invocation form. Switch `main` to @app.callback(invoke_without_command=True) so the default invocation works without a subcommand while list-configs remains available as an explicit subcommand. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 80aa762 commit fda3bcd

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/webwright/run/cli.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
DEFAULT_CONFIGS = ["base.yaml", "model_openai.yaml"]
1818

19-
app = typer.Typer(no_args_is_help=True)
19+
app = typer.Typer()
2020
console = Console(highlight=False)
2121

2222

@@ -142,15 +142,21 @@ def list_configs() -> None:
142142
console.print(path.name)
143143

144144

145-
@app.command()
145+
@app.callback(invoke_without_command=True)
146146
def main(
147-
task: str = typer.Option(..., "-t", "--task", help="Natural language task description."),
147+
ctx: typer.Context,
148+
task: str | None = typer.Option(None, "-t", "--task", help="Natural language task description."),
148149
task_id: str | None = typer.Option(None, "--task-id", help="Optional identifier used in the output directory name."),
149150
start_url: str | None = typer.Option(None, "--start-url", help="Optional starting URL for the task."),
150151
config_spec: list[str] = typer.Option(DEFAULT_CONFIGS, "-c", "--config"),
151152
output_dir: Path | None = typer.Option(None, "-o", "--output-dir"),
152153
debug: bool = typer.Option(False, "--debug", help="Launch headed local Playwright with devtools and keep it open for inspection."),
153154
) -> Any:
155+
if ctx.invoked_subcommand is not None:
156+
return
157+
if task is None:
158+
console.print(ctx.get_help())
159+
raise typer.Exit()
154160
return run_one(
155161
task=task,
156162
task_id=task_id,

0 commit comments

Comments
 (0)