yannoff/console

[help] Wrong arg display order in usage line

Closed this issue · 1 comments

Given the following configuration:

class HelloCommand extends Command
{
    public function configure()
    {
        $this
            // ...
            ->addArgument(
                'arg-1',
                Argument::REQUIRED,
                '1st argument (Required)'
            )
            ->addArgument(
                'arg-2',
                Argument::OPTIONAL,
                '2nd argument (Optional)'
            )
            ->addArgument(
                'arg-3',
                Argument::REQUIRED,
                '3rd argument (Required)'
            )
            // ...
    }
    // ....
}

Here is the output:

$ bin/demo help hello
Usage
        bin/demo hello [options] [--] <arg-1> <arg-3> [<arg-2>]
Description
        Hello world
Arguments
        arg-1              1st argument (Required)
        arg-2              2nd argument (Optional)
        arg-3              3rd argument (Required)
Options
        -h, --help         Display this help message

while it should be:

Usage
        bin/demo hello [options] [--] <arg-1> [<arg-2>] <arg-3>
Description
        Hello world
Arguments
        arg-1              1st argument (Required)
        arg-2              2nd argument (Optional)
        arg-3              3rd argument (Required)
Options
        -h, --help         Display this help message

Introduced by eee7385