Skip to content

Refactor projects command dispatch into named handlers #1292

Description

@codeforester

Problem

dispatch_projects_command() in cli/python/base_projects/engine.py builds a large dictionary of lambdas for every basectl projects subcommand. The function works, but the router is now long and each branch is harder to test or reason about independently.

This is a maintainability issue rather than a correctness bug.

Evidence:

  • dispatch_projects_command() spans the command selection and handler table in one function.
  • The handlers dictionary contains many lambdas that close over different combinations of ctx, command_arguments, options, and resolver.
  • Similar command paths would be easier to test if the routing functions were named helpers with explicit parameters.

Desired outcome

The projects command router should stay small and readable, with dispatch branches moved into named helper functions where that makes behavior easier to test.

Scope

  • Extract the larger or repeated lambda bodies into private named helpers.
  • Keep command names, argument validation, exit codes, and user-visible errors unchanged.
  • Add or update focused tests for any extracted paths that currently lack direct coverage.

Non-goals

  • Redesigning the basectl projects command surface.
  • Changing workspace/project manifest behavior.
  • Introducing a new command framework.

Acceptance criteria

  • dispatch_projects_command() is materially shorter and primarily routes commands.
  • Handler behavior remains unchanged for supported and unsupported commands.
  • Existing Python tests pass, with focused coverage for any newly isolated helpers where useful.

Demo impact

None.

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions