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

[WIP] [Console] Added Console arguments documentation #3744

Closed
wants to merge 2 commits into from

Conversation

mickaelandrieu
Copy link
Contributor

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
Copy link
Member

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?

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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.

@mickaelandrieu
Copy link
Contributor Author

@wouterj thanks a lot for this ! Maybe should we notice this on the documentation:
What do you think ?

@wouterj
Copy link
Member

wouterj commented Apr 1, 2014

@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.

@mickaelandrieu
Copy link
Contributor Author

@wouterj as far as I know it's not documented yet.
I will improve my PR to document this behavior too ;)

PS: can I use your examples or did you prefer to do your own PR ?

@wouterj
Copy link
Member

wouterj commented Apr 1, 2014

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.

@mickaelandrieu mickaelandrieu changed the title Added a little sample on Option uses with "spaces" [Console] Added Console arguments documentation Apr 8, 2014
@mickaelandrieu
Copy link
Contributor Author

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
Copy link
Member

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

Copy link
Contributor Author

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

@wouterj
Copy link
Member

wouterj commented Apr 9, 2014

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:".

@mickaelandrieu
Copy link
Contributor Author

@wouterj I'm working on it, "stay tuned" 💃

@wouterj
Copy link
Member

wouterj commented May 21, 2014

@mickaelandrieu what is the status of this?

@wouterj wouterj changed the title [Console] Added Console arguments documentation [WIP] [Console] Added Console arguments documentation May 21, 2014
@mickaelandrieu
Copy link
Contributor Author

@wouterj I'm very busy for now :/ but I will finish this.

@xabbuh
Copy link
Member

xabbuh commented Aug 8, 2014

ping @mickaelandrieu

@mickaelandrieu
Copy link
Contributor Author

aww I'll try to finish this one tommorow, only need text documentation illustrated by examples provided by @wouterj right ?

@xabbuh
Copy link
Member

xabbuh commented Aug 8, 2014

@mickaelandrieu I think so.

@wouterj
Copy link
Member

wouterj commented Aug 9, 2014

@mickaelandrieu correct

@xabbuh
Copy link
Member

xabbuh commented Oct 7, 2014

@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.

@mickaelandrieu
Copy link
Contributor Author

For now, I don't have time :/

I agree to let someone finish this.

Sorry for the inconvenience

@wouterj
Copy link
Member

wouterj commented Oct 7, 2014

I'll finish it, no problem. Thanks for starting this!
Op 7 okt. 2014 14:43 schreef "Mickaël Andrieu" [email protected]:

For now, I don't have time :/

I agree to let someone finish this.

Sorry for the inconvenience


Reply to this email directly or view it on GitHub
#3744 (comment).

xabbuh added a commit to xabbuh/symfony-docs that referenced this pull request Nov 1, 2014
@xabbuh xabbuh mentioned this pull request Nov 1, 2014
@xabbuh
Copy link
Member

xabbuh commented Nov 1, 2014

@mickaelandrieu Thank you very much for starting this great work! I took this over in #4405.

@xabbuh xabbuh closed this Nov 1, 2014
@mickaelandrieu mickaelandrieu deleted the patch-1 branch November 1, 2014 12:28
xabbuh added a commit to xabbuh/symfony-docs that referenced this pull request Nov 1, 2014
xabbuh added a commit to xabbuh/symfony-docs that referenced this pull request Nov 7, 2014
weaverryan added a commit that referenced this pull request Dec 7, 2014
This PR was merged into the 2.3 branch.

Discussion
----------

Finish 3744

This finishes the great pull request started by @mickaelandrieu in #3744.

Commits
-------

1ce59ee finish #3744
f503596 [WIP] - Console add Console arguments page
d2b69b6 Added a little sample on Option uses with "spaces"
weaverryan added a commit that referenced this pull request Dec 7, 2014
* 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
weaverryan added a commit that referenced this pull request Dec 7, 2014
* 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
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