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.
Problem
dispatch_projects_command()incli/python/base_projects/engine.pybuilds a large dictionary of lambdas for everybasectl projectssubcommand. 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.ctx,command_arguments,options, andresolver.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
Non-goals
basectl projectscommand surface.Acceptance criteria
dispatch_projects_command()is materially shorter and primarily routes commands.Demo impact
None.