laminas / laminas-cli

Console command runner, exposing commands written in Laminas MVC and Mezzio components and applications
https://docs.laminas.dev/laminas-cli
BSD 3-Clause "New" or "Revised" License
55 stars 22 forks source link

Command aliases are not supported #79

Closed boesing closed 2 years ago

boesing commented 2 years ago

Bug Report

Q A
Version(s) 1.1.0

Summary

Command aliases as supported in symfony/console are not supported. I am actually migrating a project from zf-console to laminas-cli. A "common" way to declare commands with symfony/console is to group commands with colons (:, like module:command).

To keep BC compatibility with systemd timers (cronjobs), I wanted to add the old command name (which has the format command-module) as an alias.

Current behavior

When just printing help, the command is printed with its aliased name. When executing the command, AbstractContainerCommandLoader will only take those commands into account which are exclusively mapped in laminas-cli.commands.

How to reproduce

[
    'laminas-cli' => [
        'commands' => [
            'foo' => FooCommand::class,
        ],
    ],
]
class FooCommand extends Command
{
     protected function configure(): void
    {
        $this->setAliases([
            'foo-alias',
        ]);
    }
}
vendor/bin/laminas foo-alias

  Command "foo-alias" is not defined.  

Expected behavior

FooCommand is being executed.

boesing commented 2 years ago

Temporary workaround is to add all aliases to the commands map but I would prefer having this handled by this component on its own.

boesing commented 2 years ago

Seems to work now. Not sure in which release this got fixed but its not an issue anymore.