-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
[WIP] [Console] Added Console arguments documentation #3744
Conversation
mickaelandrieu
commented
Apr 1, 2014
Q | A |
---|---|
Doc fix? | yes |
New docs? | no |
Applies to? | 2.3, 2.4, 2.5 |
Fixed tickets? | no |
@@ -292,7 +292,7 @@ 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`` or ``--yell=loud`` work). Options can also be configured to | |||
``--yell`` or ``--yell=loud`` or ``--yell loud`` work). Options can also be configured to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that this does always work. If the value for the --yell
option is optional loud
would be treated as an argument, won't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, it will be treated as the value being provided
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does : symfony/symfony#10603 (comment)
It's a little bit weird indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird. But if it is intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behaviour is following the docopt standards.
Assume the following InputDefinition:
new InputDefinition(array(
new InputOption('foo', 'f'),
new InputOption('bar', 'b', InputOption::VALUE_REQUIRED),
new InputOption('cat', 'c', InputOption::VALUE_OPTIONAL),
));
The behaviour is:
Input | Values |
---|---|
--bar=Hello |
foo = false, bar = "Hello" |
--bar Hello |
foo = false, bar = "Hello" |
-b Hello |
foo = false, bar = "Hello" |
-b=Hello |
foo = false, bar = "=Hello" |
-bHello |
foo = false, bar = "Hello" |
-fbHello |
foo = true, bar = "Hello" |
-fcHello -b World |
foo = true, bar = "World", cat = "Hello" |
-cfHello -b World |
foo = false, bar = "World", cat = "fHello" |
-cbHello |
cat = "bHello", bar = null |
Now, assume there is also an optional argument in the input definition:
new InputDefinition(array(
// ...
new InputArgument('qux', InputArgument::OPTIONAL),
));
The behaviour now:
Input | Values |
---|---|
--bar Hello |
bar = "Hello", qux = null |
--bar Hello World |
bar = "Hello", qux = "World" |
--bar Hello --cat World |
bar = "Hello", cat = "World", qux = null |
--bar Hello --cat -- World |
bar = "Hello", cat = null, qux = "World" |
-b Hello -c World |
bar = "Hello", cat = "World", qux = null |
The fourth example shows the special --
seperator which -as you can read in docopt- seperates the options from the arguments. By that, World
is no longer interpreted as a value of the cat
option (which has an optional value), but as the value for the argument.
@wouterj thanks a lot for this ! Maybe should we notice this on the documentation: |
@mickaelandrieu we shoul definitely document this behaviour if it is not done yet. Btw, please note that I updated it with more examples, also using arguments. |
@wouterj as far as I know it's not documented yet. PS: can I use your examples or did you prefer to do your own PR ? |
You can always use my examples in OSS :) (and especially in the Symfony docs). However you need to make it somewhat nice to read, not this reference like table thing. |
Thanks to your useful samples, I've improved my work with yours :) Let me know if it's good enough to be added to docs. |
.. index:: | ||
single: Console; Console arguments | ||
|
||
Understand how are handled Console arguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How Console Arguments are Handled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, modified by How Console Arguments are handled
Thank you @mickaelandrieu. However, I would rather want text instead of a table full of examples. Then after the text, we can say "For examples, see this table:". |
@wouterj I'm working on it, "stay tuned" 💃 |
@mickaelandrieu what is the status of this? |
@wouterj I'm very busy for now :/ but I will finish this. |
ping @mickaelandrieu |
aww I'll try to finish this one tommorow, only need text documentation illustrated by examples provided by @wouterj right ? |
@mickaelandrieu I think so. |
@mickaelandrieu correct |
@mickaelandrieu Do you have time to finish this? If you don't have the time, someone could take this over and finish the nice work you did so far. |
For now, I don't have time :/ I agree to let someone finish this. Sorry for the inconvenience |
I'll finish it, no problem. Thanks for starting this!
|
@mickaelandrieu Thank you very much for starting this great work! I took this over in #4405. |
* 2.3: Fixed typos Update web_server_configuration.rst Update web_server_configuration.rst remove service class parameters Some fixes backport service factory improvements Minor standard fix for best practices guide Minor tweak Don't use form() helper Apply best practices to forms Use AppBundle instead of AcmeStoreBundle Other minor fixes Use AppBundle instead of AcmeDemoBundle link to a bundle's current (not master) docs finish #3744 [WIP] - Console add Console arguments page Added a little sample on Option uses with "spaces" Conflicts: components/map.rst.inc
* 2.5: Fixed typos Update web_server_configuration.rst Update web_server_configuration.rst remove service class parameters Some fixes backport service factory improvements Minor standard fix for best practices guide Minor tweak Don't use form() helper Apply best practices to forms Use AppBundle instead of AcmeStoreBundle Other minor fixes Use AppBundle instead of AcmeDemoBundle link to a bundle's current (not master) docs finish #3744 [WIP] - Console add Console arguments page Added a little sample on Option uses with "spaces" Conflicts: book/forms.rst components/dependency_injection/factories.rst cookbook/profiler/matchers.rst cookbook/security/securing_services.rst