diff --git a/README.md b/README.md index 891bbd7..0da4671 100644 --- a/README.md +++ b/README.md @@ -198,13 +198,14 @@ python -m webwright.run.cli \ ### 🚩 Flags -| Flag | Description | -|------|-------------| +| Flag / Command | Description | +|----------------|-------------| | `-c` | Config file(s) from `src/webwright/config/` (stackable). | | `-t` | Task instruction. | | `--start-url` | Initial page. | | `--task-id` | Output subfolder name. | | `-o` | Output directory. | +| `list-configs` | Print all available built-in config file names (`python -m webwright.run.cli list-configs`). | --- diff --git a/src/webwright/run/cli.py b/src/webwright/run/cli.py index 343ab70..561c4c5 100644 --- a/src/webwright/run/cli.py +++ b/src/webwright/run/cli.py @@ -8,7 +8,7 @@ from rich.console import Console from webwright.agents import get_agent -from webwright.config import get_config_from_spec, snapshot_config_specs +from webwright.config import builtin_config_dir, get_config_from_spec, snapshot_config_specs from webwright.environments import get_environment from webwright.models import get_model from webwright.utils.serialize import UNSET, recursive_merge @@ -17,7 +17,7 @@ DEFAULT_CONFIGS = ["base.yaml", "model_openai.yaml"] -app = typer.Typer(no_args_is_help=True) +app = typer.Typer() console = Console(highlight=False) @@ -134,10 +134,22 @@ def run_one( return result -@app.command() +@app.command("list-configs") +def list_configs() -> None: + """List all available built-in config files.""" + configs = sorted(builtin_config_dir.glob("*.yaml")) + if not configs: + console.print("No config files found.") + return + for path in configs: + console.print(path.name) + + +@app.callback(invoke_without_command=True) def main( - task: str = typer.Option( - ..., "-t", "--task", help="Natural language task description." + ctx: typer.Context, + task: str | None = typer.Option( + None, "-t", "--task", help="Natural language task description." ), task_id: str | None = typer.Option( None, "--task-id", help="Optional identifier used in the output directory name." @@ -153,6 +165,11 @@ def main( help="Launch headed local Playwright with devtools and keep it open for inspection.", ), ) -> Any: + if ctx.invoked_subcommand is not None: + return + if task is None: + console.print(ctx.get_help()) + raise typer.Exit() return run_one( task=task, task_id=task_id,