Pool console: full signature syntax, original exceptions, and resilient command discovery - #350
Open
techmahedy wants to merge 1 commit into
Open
techmahedy wants to merge 1 commit into
techmahedy wants to merge 1 commit into
Conversation
…nt command discovery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Summary
Doppar runs on Symfony Console 8.1 (
^8.1, 8.1.5 installed). An audit ofpoolagainst it found no removed or deprecated API in use: all 68 commands load,--helprenders for every one, and there are no warnings or deprecations. It did find three real problems, fixed here, and one gap in the signature parser, which this PR closes.Bug fixes
Command::execute()caught everything, logged it and threw a barenew \Exception($e->getMessage()). Every failure was reported as "In Command.php line 150", the real class, code and trace were lost (even with-vvv), and ifLog::error()itself threw, that error replaced the real one. The exception is now logged inside a guard and rethrown as is.poolcommand. Discovery built every.phpfile underCommands/andsrc/Schedule/Commands, so a helper, trait, interface, abstract class, or a command whose constructor throws (including a syntax error in a user command) made evenpool listfail. Discovery now skips anything that is not a concreteSymfony\Component\Console\Command\Commandsubclass, and a command that cannot be built is skipped withSkipped command [Class]: reasonon stderr while the rest load.parseSignature()ignored any definition it could not parse.{name=guest},{files*}and{--cache!}registered nothing (the command then failed at runtime with "argument does not exist"), and{--tag=*}became a plain string option whose default was the literal text*. Unparseable definitions now throw aLogicExceptionnaming the command class and the definition.New: full signature syntax
Exposes the
InputArgument/InputOptionfeatures that the parser did not, including Symfony 8.1's boolean default on negatable options:{name=guest}{files*}/{files?*}[]when omitted){--tag=*}--tag=a --tag=b), returned as an array{--cache!}--cache,--no-cache;nullwhen neither is passed{--cache!=true}/{--cache!=false}Everything that parsed before parses the same way:
{name},{name?},{--flag},{-f|--flag},{--opt=},{--opt=default}, and:descriptions. Symfony's own rules still apply (an array argument must be last, a required argument cannot follow an optional one) and surface as itsLogicException.Behaviour changes to be aware of
handle()are now reported with their real class and location instead of a genericExceptionfromCommand.php. The exit code follows Symfony's rule for the original exception's code.Files
src/Phaseolies/Console/Schedule/Command.php:parseSignature()split intoaddArgumentFromDefinition()/addOptionFromDefinition();execute()rethrows the original.src/Phaseolies/Console/Command.php:isCommandClass(), per-command isolation inregisterCommands(), overridablereportSkippedCommand().tests/Console/CommandSignatureGrammarTest.php: new.Checklist