feat(console): add run command to invoke other registered commands#143
feat(console): add run command to invoke other registered commands#143bedus-creation wants to merge 1 commit into
Conversation
Add a built-in 'run' console command that forwards arguments to another registered command via Cleo's Command.call and propagates its exit code. Usage: artisan run db:migrate artisan run db:seed -- --force
bedus-creation
left a comment
There was a problem hiding this comment.
Code Review verdict: APPROVE (posting as a comment — GitHub blocks formal self-approval since the authenticated account authored this PR). Verified locally on branch task/run-console-command.
Review against the requested dimensions:
- Clean/minimal wrapper, no core abstraction changes ✅ — 35-line
RunCommand+ a singleself.commands([PublishCommand, RunCommand])line inAppProvider.boot(). No changes to Container/Application/Provider/Model. - Exit-code propagation ✅ —
handle()returnsself.call(...)directly;test_propagates_non_zero_exit_codeconfirms exit_code=5 → status 5. - Graceful unknown-command handling ✅ — an unknown name raises Cleo's
CleoCommandNotFoundError, which the inheritedConsoleApplication/Cleo run loop renders as a cleanThe command "x" does not exist.message and exits non-zero (1). Verified empirically — no raw traceback. - Meaningful test coverage ✅ — 4 tests (positional forwarding, exit-code propagation, option forwarding after
--, no-args). All pass locally in 0.04s. - Focused diff ✅ — no
uv.lock, no version bumps; only the 4 intended files.
Code quality: type hints present, args or [] guards None, and the shlex.join([command, *forwarded]) leading-name trick is correct and well-documented.
Non-blocking nit (optional): consider adding a test that pins the unknown-command path (assert it surfaces CleoCommandNotFoundError / non-zero exit), since that behavior is currently only inherited, not locked by a test.
Holding merge until Console QA reports PASS on task #476, per PM.
|
Closing — this was the wrong interpretation. The requirement is a programmatic Application.run() API, not a new artisan CLI command. Superseded by the work in task #478. |
Summary
Adds a built-in
runconsole command to the core framework that invokes another registered console command programmatically (Laravelcall-style), forwarding arguments and propagating the called command's exit code.What it does
RunCommand(console/run_command.py) — a thin wrapper over Cleo'sCommand.call(name, args).command_nameargument and an optional variadicargsargument.--(standard Cleo option-terminator), e.g.run db:seed -- --force.AppProvider.boot()alongsideprovider:publish.Implementation note
Cleo's
callre-tokenizes the args string and binds it against the target command merged with the application definition, whose first positional is the command name. The name therefore leads the forwarded string so the first real argument isn't swallowed.Tests
tests/console/test_run_command.pycovers:--All 4 pass; existing serve-command tests remain green.