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

[console] Requested command wrongly recognized as ambiguous #25355

Closed
Chi-teck opened this issue Dec 6, 2017 · 1 comment
Closed

[console] Requested command wrongly recognized as ambiguous #25355

Chi-teck opened this issue Dec 6, 2017 · 1 comment

Comments

@Chi-teck
Copy link
Contributor

Chi-teck commented Dec 6, 2017

Q A
Bug report? yes
Symfony version 3.2.14

Simple script to demonstrate the problem

#!/usr/bin/env php
<?php

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

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

$application = new Application();

$code = function(InputInterface $input, OutputInterface $output) {
  $output->writeln('It works!');
};

$application
  ->register('test-foo')
  ->setAliases(['test'])
  ->setCode($code);

$application
  ->register('test-bar')
  ->setCode($code);

$application->run();
 # It works!
./test.php test-foo

 # It works!
./test.php test-bar

# Command "test" is ambiguous (test-foo, test-bar).
./test.php test

The last example should run test-foo command because it has exact same alias as requested command name.

@Simperfit
Copy link
Contributor

I'm going to fix this one.

nicolas-grekas added a commit that referenced this issue May 9, 2019
…as ambiguous when using register (Simperfit)

This PR was merged into the 3.4 branch.

Discussion
----------

[Console] Commands with an alias should not be recognized as ambiguous when using register

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25355
| License       | MIT
| Doc PR        |

I think when passing an alias, it should not be treated as a ambiguous command since it's configured to response to it.

I've [pushed a commit](Simperfit/symfony-reproducer@2f5209a) that reproduce the bug and with this patch it does work.

Commits
-------

ae7ee46 [Console] Commands with an alias should not be recognized as ambiguous
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