Skip to content

[Console] --help is not preserved when a command is not found, and a proposition is made #62618

@lyrixx

Description

@lyrixx

Symfony version(s) affected

all, I guess

Description

$ php index.php  command --help

                                     
  Command "command" is not defined.  
                                     

 Do you want to run "my:command" instead?  (yes/no) [no]:
 > yes

Hello, World!
  • Here, I passed the --help flag on a command that does not exist.
  • Symfony find the real command, and made a proposition.
  • I type yes, to the proposition
  • Symfony runs the command, but without the --help flag

I think the --help should be preserved

How to reproduce

<?php

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;

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

$app = new Application('My Console App', '1.0.0');
$command = new Command();
$command->setName('my:command')
    ->setDescription('This is my custom command.')
    ->setCode(function () {
        echo "Hello, World!\n";

        return 1;
    });

$app->addCommand($command);

$app->run();

Then, execute:

php index.php  command --help

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions