Skip to content
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

Add 2 solutions for the 'option with optional argument' problem #9560

Closed
wants to merge 4 commits into from

Conversation

Jean85
Copy link
Contributor

@Jean85 Jean85 commented Apr 5, 2018

While working on facile-it/paraunit#121, I discovered a tricky case with the Console component: using an option with an optional argument seemed impossible! The doc said:

There is nothing forbidding you to create a command with an option that optionally accepts a value. However, there is no way you can distinguish when the option was used without a value (command --language) or when it wasn't used at all (command). In both cases, the value retrieved for the option will be null.

This is NOT TRUE. I've found two possible solutions to this issue (one myself, one in symfony/symfony#11572 (comment)) and this PR introduces them in the docs. I've also moved around the two tips/cautions which were at the end of the article, because with my reword it seemed nicer to me.

@wouterj
Copy link
Member

wouterj commented May 5, 2018

Hi @Jean85! Thanks a lot for this PR, it seems to read nicer this way!

I like your second option way more than your first one. The first one is some internal logic, which the framework wants to hide from you by providing the input options and arguments.

What do you think about only documenting the second option? Giving readers a choice means we have to explain in which case to use (1) or (2), and I can't come up with a reason to use (1). :)

I'm sorry to have such a delayed review of this PR. If you can comment or update the PR, please do so and otherwise I'm happy to take this PR over to make it mergable :)

@Jean85
Copy link
Contributor Author

Jean85 commented May 6, 2018

No problem @wouterj! I've simplified my PR leaving just (2). Now it's back to you to review 😉

@javiereguiluz
Copy link
Member

@Jean85 thanks for taking the time to improve the docs about this. It's an edge-case, but it's important to explain it well. I did some rewords to simplify some phrases and replace some advanced English words for other basic words (we need to do that to keep the docs approachable for people without an advanced English level). We merged it on 2.8 (the oldest maintained branch)

javiereguiluz added a commit that referenced this pull request May 27, 2018
…roblem (Jean85, javiereguiluz)

This PR was submitted for the 2.7 branch but it was merged into the 2.8 branch instead (closes #9560).

Discussion
----------

Add 2 solutions for the 'option with optional argument' problem

While working on facile-it/paraunit#121, I discovered a tricky case with the Console component: using an option with an optional argument seemed impossible! The doc said:

> There is nothing forbidding you to create a command with an option that optionally accepts a value. However, there is no way you can distinguish when the option was used without a value (command --language) or when it wasn't used at all (command). In both cases, the value retrieved for the option will be null.

This is NOT TRUE. I've found two possible solutions to this issue (one myself, one in symfony/symfony#11572 (comment)) and this PR introduces them in the docs. I've also moved around the two tips/cautions which were at the end of the article, because with my reword it seemed nicer to me.

Commits
-------

d3f254d Minor simplifications
1aad365 Minor reword
99f9e3f Simplify the explanation leaving just one solution
a05b002 Add 2 solutions for the 'option with optional argument' problem
javiereguiluz added a commit that referenced this pull request May 27, 2018
…roblem (Jean85, javiereguiluz)

This PR was submitted for the 2.7 branch but it was merged into the 2.8 branch instead (closes #9560).

Discussion
----------

Add 2 solutions for the 'option with optional argument' problem

While working on facile-it/paraunit#121, I discovered a tricky case with the Console component: using an option with an optional argument seemed impossible! The doc said:

> There is nothing forbidding you to create a command with an option that optionally accepts a value. However, there is no way you can distinguish when the option was used without a value (command --language) or when it wasn't used at all (command). In both cases, the value retrieved for the option will be null.

This is NOT TRUE. I've found two possible solutions to this issue (one myself, one in symfony/symfony#11572 (comment)) and this PR introduces them in the docs. I've also moved around the two tips/cautions which were at the end of the article, because with my reword it seemed nicer to me.

Commits
-------

7be002b Add 2 solutions for the 'option with optional argument' problem
@Jean85 Jean85 deleted the improve-input-article branch May 28, 2018 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants