Skip to content

Conversation

@ogizanagi
Copy link
Contributor

@ogizanagi ogizanagi commented Nov 30, 2016

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #20237, #13220 (comment)
License MIT
Doc PR N/A

Before

screenshot 2016-11-30 a 19 23 17

After

screenshot 2016-11-30 a 19 23 46

@rquadling and @leofeyer deserve the credit for reporting the issue and suggesting the proper fix. I've only executed it.


Show code to reproduce:
<?php

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

require __DIR__.'/../vendor/autoload.php';

(new Application())
    ->add(new class extends Command {
        protected function configure()
        {
            $description = "One of:" . array_reduce(['purge', 'truncate', 'delete', 'insert', 'select'], function ($value, $previous = '') {
                    return "$value\n- $previous";
            });

            $this
                ->setName('execute')
                ->addArgument('action', InputArgument::REQUIRED, $description)
                ->addOption('another-one', 'a', InputOption::VALUE_OPTIONAL, $description)
            ;
        }
    })
    ->getApplication()
    ->run(new ArgvInput())
;

@chalasr
Copy link
Member

chalasr commented Dec 1, 2016

👍

Status: reviewed
(I asked myself about if it wouldn't be better to keep a small indentation, but really not sure)

@ogizanagi
Copy link
Contributor Author

(I asked myself about if it wouldn't be better to keep a small indentation, but really not sure)

I guess it's the developper responsibility to add it himself when required, but it makes no sense to enforce a global rule for this.

@fabpot
Copy link
Member

fabpot commented Dec 2, 2016

Thank you @ogizanagi.

@fabpot fabpot merged commit 18fc6b5 into symfony:2.7 Dec 2, 2016
fabpot added a commit that referenced this pull request Dec 2, 2016
…ions (ogizanagi)

This PR was merged into the 2.7 branch.

Discussion
----------

[Console] Fix wrong handling of multiline arg/opt descriptions

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20237, #13220 (comment)
| License       | MIT
| Doc PR        | N/A

### Before

<img width="1072" alt="screenshot 2016-11-30 a 19 23 17" src="https://cloud.githubusercontent.com/assets/2211145/20765428/8b622304-b732-11e6-911b-b169e9aed5fd.PNG">

### After

<img width="1074" alt="screenshot 2016-11-30 a 19 23 46" src="https://cloud.githubusercontent.com/assets/2211145/20765432/9159a53e-b732-11e6-909f-ec8107c78fed.PNG">

@rquadling and @leofeyer deserve the credit for reporting the issue and suggesting the proper fix. I've only executed it.

---

<details>
<summary>Show code to reproduce:</summary>

```php
<?php

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

require __DIR__.'/../vendor/autoload.php';

(new Application())
    ->add(new class extends Command {
        protected function configure()
        {
            $description = "One of:" . array_reduce(['purge', 'truncate', 'delete', 'insert', 'select'], function ($value, $previous = '') {
                    return "$value\n- $previous";
            });

            $this
                ->setName('execute')
                ->addArgument('action', InputArgument::REQUIRED, $description)
                ->addOption('another-one', 'a', InputOption::VALUE_OPTIONAL, $description)
            ;
        }
    })
    ->getApplication()
    ->run(new ArgvInput())
;
```
</details>

Commits
-------

18fc6b5 [Console] Fix wrong handling of multiline arg/opt descriptions
@ogizanagi ogizanagi deleted the fix/2.7/console/wrong_multiline_descr branch December 2, 2016 12:01
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