Skip to content

Commit 2eddcf1

Browse files
greg-1-andersonjaviereguiluz
authored andcommitted
Clarify Symfony Console option conventions
Add link to docopt standard and describe Symfony limitation in using spaces in option name/value pairs.
1 parent 2cf4122 commit 2eddcf1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

console/input.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,19 @@ You can combine ``VALUE_IS_ARRAY`` with ``VALUE_REQUIRED`` or
219219
Similarly, due to a PHP limitation, there is no way to pass an empty string
220220
as the value of an option. In ``command --prefix`` and ``command --prefix=''``
221221
cases, the value of the ``prefix`` option will be ``null``.
222+
223+
Note that to comply with the `docopt standard`_, long options can specify their
224+
values after a white space or an ``=`` sign (e.g. ``--iterations 5`` or
225+
``--iterations=5``), but short options can only use white spaces or no
226+
separation at all (e.g. ``-i 5`` or ``-i5``).
227+
228+
.. _`docopt standard`: http://docopt.org/
229+
230+
.. tip::
231+
232+
While it is possible to use whitespace to separate an option from its value,
233+
using this form leads to an ambiguity should the option appear before the
234+
command name. In other words, ``php bin/console --iterations 5 app:greet Fabien``
235+
is ambiguous; Symfony would interpret ``5`` as the command name. To avoid
236+
this situation, always place options after the command name, or avoid using
237+
a space to separate the option name from its value.

0 commit comments

Comments
 (0)