Skip to content

[Console] Unexpected unsupported command option shortcut #18856

Closed
@nico-incubiq

Description

@nico-incubiq

Hi,
I am using Symfony 2.8.6, and after creating a new Command, I stumbled upon an unexpected error:

An argument with name "command" already exists.
[Symfony\Component\Console\Exception\LogicException]
An argument with name "command" already exists.

After trying a lot of different solutions, I found out that the error had to do with the option shortcut I used:

$this->setName('my:super:command')
->setAliases(['my:super:commandalias'])
->setDescription('Performs some irrelevant work.')
->addOption('survey', 's', InputOption::VALUE_REQUIRED, 'My option with a shortcut.')

After changing the alias (or setting it to null), the error just stopped popping out.
Is there any obvious reason I am missing here, or is this a bug?
Because to my knowledge "s" is not used anywhere else.

Furthermore, the error is awkwardly cryptic and gave me a hard time debugging this.

Regards,
Nicolas

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