infureal / artisan-gui

Simple but yet powerful library for running almost all artisan commands.
https://packagist.org/packages/infureal/artisan-gui
356 stars 56 forks source link

Array option problems #14

Closed vlehnert closed 3 years ago

vlehnert commented 3 years ago

Hello,

Thank you for this great package ! It seems that that the array options haven't been taken into account (https://laravel.com/docs/8.x/artisan#option-arrays)

I managed to add my own command in the config, and it shows in the interface. However, I'm running into a problem with array options, because I can have several options for the same command.

My command migrates many different migration files to different external databases at the same time, here's what it looks like :

protected $signature = 'migrate:custom {artisanCommand : artisan command (migrate, migrate:rollback ...)} {--connection=* : database connection to migrate}';

Usage:

php artisan migrate:custom migrate --connection=databaseconnect1 --connection=databaseconnect2

To fix the backend I just made a quick change to GuiController:34 (and I can run the command several times)

    foreach ($data as $key => $value) {
        if ($command->getDefinition()->hasOption($key)) {
            $keyParams = "--{$key}";
            if ($command->getDefinition()->getOption($key)->isArray()) {
                $params[$keyParams][] = $value;
            } else {
                $params[$keyParams] = $value;
            }
        } else {
            $params[$key] = $value;
        }
    }

For the front-end it would be nice to have another field added once the first one is filled in, or to be able to differentiate arrays some other way :)

infureal commented 3 years ago

Hello, array options are implemented in version 2.0.0. It's on beta right now, but you can test it on your own