8000 Reworded the explanation about optional command options by javiereguiluz · Pull Request #5009 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Reworded the explanation about optional command options #5009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 14, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Reworded the explanation about optional command options
  • Loading branch information
javiereguiluz committed Feb 18, 2015
commit 1b5fcf0a524f433abc7651ab7243a23ec9bfddcd
9 changes: 6 additions & 3 deletions components/console/introduction.rst
8000
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,12 @@ declare a one-letter shortcut that you can call with a single dash like

.. tip::

It is also possible to make an option *optionally* accept a value (so that
``--yell``, ``--yell=loud`` or ``--yell loud`` work). Options can also be configured to
accept an array of values.
It may look that it's possible to make an option *optionally* accept a value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the option optionally here sounds very confusing, can it be reworded too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't come up with anything else... (btw, you're back reviewing, awesome!).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove it all together and say:

There is nothing forbidding you to create a command with an input option set to
InputOption::OPTIONAL mode. You will just not be able to distinguish when the
flag for that option was used without a value (``command --yell``) or when it was
not used at all (``command``). The value retrieved for the option will be the
same ``null``.

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your explanation ... but I've tweaked some minor parts of it. Thanks.

(so that ``--yell`` or ``--yell=loud`` work). However, if you call a command
with an option without a value, you'll retrieve ``null`` as the option's value
which is the same when you omit the option. In practice, this means that a
command cannot distinguish between passing an option without a value and not
passing that very same option.

For example, add a new option to the command that can be used to specify
how many times in a row the message should be printed::
Expand Down
0