You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
What OS are you observing this on? We have used these flags successfully on
zf-deploy (see its route configuration).
One note: if the glad should allow an argument, you need to use special
notation:
[--flag|-f]:flag
I suggest looking at the tests,
as those demonstrate the full range of options supported — which include
the scenario you indicated. I cannot reproduce the issue you present on
Linux, which leads me to believe it may be an environmental issue.
On Nov 14, 2015 1:12 PM, "hschletz" notifications@github.com wrote:
This is my simple route definition:
'[--flag|-f] '
Only "-f" and "-flag" match, "--flag" does not. According to the
documentation, "--flag" should match, which would also follow common
conventions.
—
Reply to this email directly or view it on GitHub #6.
I forgot to test with real application. The problem only occurs during unit tests for my controller. It is caused by the command line parser regex in AbstractControllerTestCase::run():
This would be correct in case of value parameters, but not with simple flags. But even with value parameters, this would not work as documented in practice, as demonstrated by this simple script:
The arguments are passed according to my route specification, which is why the script works as expected when run from the command line, but the unit test fails.
Out of curiosity, I changed the route to "--flag=". It turns out that "--flag=arg" works as expected, but "--flag arg" is still treated as separate parameters due to the way the OS parses command lines (I ran it on Linux BTW).
So either the request params must be concatenated if argv contains a single "--flag" instead of "--flag=arg", or the "--flag arg" variant should be removed from the documentation.
The command line parser in AbstractControllerTestCase needs to be fixed too. I doubt that a single regex will be able to handle all edge cases the same way as the OS does, like escaped quotes. For complex command lines that get parsed incorrectly, it would be nice to pass parameters as an array in the third argument to dispatch(), but currently this gets unconditionally replaced with the parsed command line for console tests.
Activity
weierophinney commentedon Nov 14, 2015
What OS are you observing this on? We have used these flags successfully on
zf-deploy (see its route configuration).
One note: if the glad should allow an argument, you need to use special
notation:
I suggest looking at the tests,
as those demonstrate the full range of options supported — which include
the scenario you indicated. I cannot reproduce the issue you present on
Linux, which leads me to believe it may be an environmental issue.
On Nov 14, 2015 1:12 PM, "hschletz" notifications@github.com wrote:
hschletz commentedon Nov 15, 2015
I forgot to test with real application. The problem only occurs during unit tests for my controller. It is caused by the command line parser regex in AbstractControllerTestCase::run():
If I dispatch "arg --flag", the command line gets broken down correctly:
but with "--flag arg" I get:
This would be correct in case of value parameters, but not with simple flags. But even with value parameters, this would not work as documented in practice, as demonstrated by this simple script:
Run it with given arguments:
The arguments are passed according to my route specification, which is why the script works as expected when run from the command line, but the unit test fails.
Out of curiosity, I changed the route to "--flag=". It turns out that "--flag=arg" works as expected, but "--flag arg" is still treated as separate parameters due to the way the OS parses command lines (I ran it on Linux BTW).
So either the request params must be concatenated if argv contains a single "--flag" instead of "--flag=arg", or the "--flag arg" variant should be removed from the documentation.
The command line parser in AbstractControllerTestCase needs to be fixed too. I doubt that a single regex will be able to handle all edge cases the same way as the OS does, like escaped quotes. For complex command lines that get parsed incorrectly, it would be nice to pass parameters as an array in the third argument to dispatch(), but currently this gets unconditionally replaced with the parsed command line for console tests.
weierophinney commentedon Dec 31, 2019
This repository has been closed and moved to laminas/laminas-console; a new issue has been opened at laminas/laminas-console#9.