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

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

Merged
merged 1 commit into from Dec 2, 2016

Conversation

Projects
None yet
4 participants
@ogizanagi
Member

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

This comment has been minimized.

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

This comment has been minimized.

Member

ogizanagi commented Dec 1, 2016

(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

This comment has been minimized.

Member

fabpot commented Dec 2, 2016

Thank you @ogizanagi.

@fabpot fabpot merged commit 18fc6b5 into symfony:2.7 Dec 2, 2016

2 of 3 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
fabbot.io Your code looks good.
Details

fabpot added a commit that referenced this pull request Dec 2, 2016

bug #20704 [Console] Fix wrong handling of multiline arg/opt descript…
…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 ogizanagi:fix/2.7/console/wrong_multiline_descr branch Dec 2, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment