8000 Global console flags don't work when providing multiple options · Issue #23876 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Global console flags don't work when providing multiple options #23876

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

Closed
Riimu opened this issue Aug 12, 2017 · 3 comments
Closed

Global console flags don't work when providing multiple options #23876

Riimu opened this issue Aug 12, 2017 · 3 comments

Comments

@Riimu
Copy link
Riimu commented Aug 12, 2017
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version v3.3.6

The parsing of global console flags is rather inconsistent with rest of the console application framework.

The Application::configureIO() uses hasParameterOption for testing flags, which in case of ArgvInput does not seem to account for multiple flags provided in a single argument. i.e. it only tests for say, -q and -n separately, but not for -qn

To illustrate the issue, let's say, for example, that we have a command like:

class FooBarCommand extends Command
{
    protected function configure()
    {
        $this->setName('say')->addOption('foo', 'f')->addOption('bar', 'b');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        if ($input->getOption('foo')) {
            $output->write('foo');
        }
        if ($input->getOption('bar')) {
            $output->write('bar');
        }
    }
}

Now, if a run a command like

> php console say -q -f -b

we get no input, as expected due to the "quiet" flag. However, should we run the command:

> php console say -qfb
foobar

We suddenly get the output "foobar". This is even a bit more confusing, since there is no error or anything to indicate that we did something wrong. The "q" flag is defined as a shortcut for "quiet", so it doesn't cause validation errors, but since the "q" flag is only noticed, if it's provided exactly in the format of "-q", it's also ignored.

Even if this is intended, it's even more confusing, since the "help" command makes no mention of the special status of the "-n" and "-q" flags which must be provided separately.

chalasr pushed a commit that referenced this issue Nov 26, 2017
…erfit)

This PR was merged into the 2.7 branch.

Discussion
----------

[Console] Fix global console flag when used in chain

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | #23876
| License       | MIT
| Doc PR        |

Because SymfonyCon is great we can create pull request in it ! (this was preparer in the plane and I can push it just right now ;))

Finished in the #SymfonyConHackday2017

Commits
-------

1f8db73 [Console] Fix global console flag when used in chain
@chalasr chalasr closed this as completed Nov 26, 2017
@chalasr chalasr reopened this Jan 27, 2018
@Simperfit
Copy link
Contributor

since the fix from @greg-1-anderson has been merged too, is this fixed ?

@xabbuh
Copy link
Member
xabbuh commented May 3, 2019

@Simperfit #24987 was reverted (see #24987 (comment)). Or do you mean another PR?

@Simperfit
Copy link
Contributor

@xabbuh Yes I'm talking about this one: #25893

@xabbuh xabbuh closed this as completed May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0