Skip to content

feat: add list-configs subcommand to CLI#31

Open
nuthalapativarun wants to merge 2 commits into
microsoft:mainfrom
nuthalapativarun:feat/list-configs-cli
Open

feat: add list-configs subcommand to CLI#31
nuthalapativarun wants to merge 2 commits into
microsoft:mainfrom
nuthalapativarun:feat/list-configs-cli

Conversation

@nuthalapativarun

Copy link
Copy Markdown

Problem

New users have no way to discover which config files are available without browsing the source tree. The -c flag requires knowing a config filename in advance, creating friction for first-time users trying to switch backends (e.g. from OpenAI to Anthropic).

Fix

Add a list-configs subcommand to the Typer app that prints the names of all .yaml files in the built-in config directory. Update the README flags table to document the new command.

Changes

  • src/webwright/run/cli.py — added list_configs() command decorated with @app.command("list-configs"); imports builtin_config_dir from webwright.config
  • README.md — added list-configs row to the flags table with usage example

Not affected

  • The existing main command — not touched; no flags changed
  • webwright/config/__init__.pybuiltin_config_dir was already exported; no changes needed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a list-configs Typer subcommand that prints the names of all built-in .yaml config files in webwright/config/, so users can discover available configs without browsing the source tree. The README flags table is updated to document the new command.

Changes:

  • New list_configs() Typer command in src/webwright/run/cli.py that globs builtin_config_dir/*.yaml and prints filenames via the existing rich console.
  • Imports builtin_config_dir from webwright.config.
  • README flags table renamed to "Flag / Command" and a list-configs row added.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/webwright/run/cli.py Registers a second Typer command (list-configs) and imports builtin_config_dir.
README.md Documents list-configs in the flags table and renames the column header.

Note: Registering a second @app.command() makes Typer require a subcommand, which breaks the existing no-subcommand invocation form documented in the README Quick Start and src/webwright/run/run_command.sh. This contradicts the PR description's claim that the main command is "not touched". See inline comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/webwright/run/cli.py
Comment on lines +134 to +142
@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)
Comment thread README.md
Comment on lines +201 to +208
| 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`). |
@nuthalapativarun

Copy link
Copy Markdown
Author

Fixed in fda3bcd.

Converted main from @app.command() to @app.callback(invoke_without_command=True). When Typer sees a callback with this flag, it invokes the callback for every execution but only runs a subcommand if one is explicitly named — so the existing python -m webwright.run.cli -c base.yaml -t "..." form continues to work unchanged, while list-configs is still reachable as an explicit subcommand.

Changed --task from required (...) to optional (None) in the callback signature (required only when no subcommand is present), and added an early return when ctx.invoked_subcommand is not None so the callback is a no-op during list-configs. No changes needed to the README Quick Start or run_command.sh.

nuthalapativarun and others added 2 commits June 4, 2026 21:01
New users have no way to discover which config files are available
without browsing the source tree. Add `python -m webwright.run.cli
list-configs` that prints all .yaml filenames from the built-in config
directory. Update the README flags table to document the new command.
…tion

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>
@nuthalapativarun nuthalapativarun force-pushed the feat/list-configs-cli branch from fda3bcd to 89276cb Compare June 5, 2026 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants