laminas / laminas-cli

Console command runner, exposing commands written in Laminas MVC and Mezzio components and applications
https://docs.laminas.dev/laminas-cli
BSD 3-Clause "New" or "Revised" License
55 stars 22 forks source link

bugfix: only use `--container` option definition to resolve container #75

Closed boesing closed 3 years ago

boesing commented 3 years ago
Q A
Bugfix yes
BC Break yes - but only on internal classes

Description

Using the ArgvInput together with the applications InputDefinition was a bad idea. The reason why ArgvInput was used was to synchronize input definition so there is no need for duplication. Sadly, the ArgvInput does some kind of validation when binding the definition and as the command definition is not yet loaded, an exception is thrown.

Since we ignore that exception and skip loading the container, the application is starting up, searches for the command, cannot find any command (as container detection was skipped) and that leads to unexpected behavior.

Symfony itself ignores validation exceptions before the command itself is loaded but that wont be a solution for this library.

To avoid being interrupted by symfony while detecting the --container option, this PR introduces a lightweight long-options detection which focuses on detecting only the --container option.

closes #74

weierophinney commented 3 years ago

Closing in favor of #76.

We can revisit this one later if that proves to be an incomplete or inflexible solution.