JN-Jones / web-artisan

A package for Laravel 4 top interact with the CLI
54 stars 11 forks source link

Cannot launch custom commands #4

Closed nbertal closed 11 years ago

nbertal commented 11 years ago

I'm trying to launch custom made commands (http://laravel.com/docs/commands) through Web Artisan, but it apparently fails to recognize options (--this) and arguments.

In order to debug a little I put the following line at the begining of the command fire() function : $this->info(options: ' . json_encode( $this->option() ));

It showed options were always set to false.

JN-Jones commented 11 years ago

As I said in #3: I'm not at home till wednesday and will test it afterwards

JN-Jones commented 11 years ago

I can't reproducce this, it works for me. Can you post your command?

nbertal commented 11 years ago

I copy here the 2 usefull excerpts of my pupdate command...

Declaring the options :

protected function getOptions()
    {
        return array(
            array('archive', 'a', InputOption::VALUE_NONE, 'Archive past events.', null),
            array('uoid', 'o', InputOption::VALUE_NONE, 'Update owners\' id.', null),
        );
    }

Main command code:

public function fire()
    {
        // retrieving options
        $options = $this->option();
        $this->info('options: ' . json_encode( $this->option() ));

        // not any of the options available -> fail
        if( !$options['archive'] && !$options['uoid'] ) {
            $this->error('You need to specify either --(a)rchive or --u(o)id');
        }
        [...]
    }

When i type: artisan command:pupdate --archive or artisan command:pupdate -a

it returns: options: {"archive":false,"uoid":false,"help":false,"quiet":false,"verbose":false,"version":false,"ansi":false,"no-ansi":false,"no-interaction":false,"env":null} You need to specify either --(a)rchive or --u(o)id

JN-Jones commented 11 years ago

Ok I can confirm it, will fix it tomorrow

nbertal commented 11 years ago

Wow, thanks ! :)