Background & Motivation
The wptgen/main.py file has grown significantly and currently houses the definitions and logic for all CLI commands (e.g., generate, chromestatus, audit, doctor, config) along with global configurations and helper functions. Furthermore, a substantial amount of code duplication exists because many commands (generate, audit, chromestatus) share identical CLI flag definitions (using Typer's Annotated[..., typer.Option(...)]).
As more features and commands are added, this file will become increasingly difficult to navigate and maintain. Splitting the CLI command definitions into separate, focused modules and extracting shared argument definitions will drastically reduce boilerplate, ensure CLI flag consistency, and improve code organization.
Proposed Changes
- Create a new directory structure for CLI components (e.g.,
wptgen/cli/).
- Deduplicate Typer Options: Create a
wptgen/cli/options.py (or arguments.py) module to define shared typer.Option aliases (e.g., ConfigOption, ProviderOption, UseReasoningOption). Update all command signatures to use these shared types.
- Extract Commands: Move the specific command logic out of
wptgen/main.py and into their own module files. For example:
wptgen/cli/commands/generate.py (for the generate and generate-single commands)
wptgen/cli/commands/chromestatus.py
wptgen/cli/commands/audit.py
wptgen/cli/commands/config.py (for the config sub-app commands)
wptgen/cli/commands/system.py (for doctor, clear-cache, version, init, and list-models)
- Extract Helpers: Extract shared helper functions (e.g.,
_check_workflow_flags, _print_workflow_banner, _workflow_error_handler, _execute_workflow) into an internal helper module like wptgen/cli/core.py to ensure clean imports and code reuse.
- Simplify
main.py: Refactor wptgen/main.py so that its primary responsibility is acting as the root CLI entry point, initializing the Typer app, applying logging configuration, and wiring up the subcommands (using app.add_typer() or direct function imports) without changing the existing command-line API structure.
Acceptance Criteria
This issue description was drafted by Gemini
Background & Motivation
The
wptgen/main.pyfile has grown significantly and currently houses the definitions and logic for all CLI commands (e.g.,generate,chromestatus,audit,doctor,config) along with global configurations and helper functions. Furthermore, a substantial amount of code duplication exists because many commands (generate,audit,chromestatus) share identical CLI flag definitions (using Typer'sAnnotated[..., typer.Option(...)]).As more features and commands are added, this file will become increasingly difficult to navigate and maintain. Splitting the CLI command definitions into separate, focused modules and extracting shared argument definitions will drastically reduce boilerplate, ensure CLI flag consistency, and improve code organization.
Proposed Changes
wptgen/cli/).wptgen/cli/options.py(orarguments.py) module to define sharedtyper.Optionaliases (e.g.,ConfigOption,ProviderOption,UseReasoningOption). Update all command signatures to use these shared types.wptgen/main.pyand into their own module files. For example:wptgen/cli/commands/generate.py(for thegenerateandgenerate-singlecommands)wptgen/cli/commands/chromestatus.pywptgen/cli/commands/audit.pywptgen/cli/commands/config.py(for theconfigsub-app commands)wptgen/cli/commands/system.py(fordoctor,clear-cache,version,init, andlist-models)_check_workflow_flags,_print_workflow_banner,_workflow_error_handler,_execute_workflow) into an internal helper module likewptgen/cli/core.pyto ensure clean imports and code reuse.main.py: Refactorwptgen/main.pyso that its primary responsibility is acting as the root CLI entry point, initializing the Typer app, applying logging configuration, and wiring up the subcommands (usingapp.add_typer()or direct function imports) without changing the existing command-line API structure.Acceptance Criteria
main.pyare relocated to separate, logically grouped modules.make presubmit(or equivalent test/lint/typecheck commands) pass without errors.This issue description was drafted by Gemini