jaz303 / phake

A rake/make clone for PHP 5.3
365 stars 27 forks source link

Invoking multiple tasks does not work #32

Closed clue closed 10 years ago

clue commented 10 years ago

Phakefile.php

task('a', function() { echo 'a'; });
task('b', function() { echo 'b'; });

Invoking phake a b:

Expected Output: ab Actual Output: a

Phake seems to ignore any additional task names and thus is not quite in line with how rake/make work.

Fix should be rather easy, but I'm opening this as a reminder for the time being. Also, we might want to discuss if we could even consider this a feature.

Personally, I've (ab)used this feature as a nicer syntax to pass additional arguments to a task like this:

task('dump', function() {
  $dump = argv(2);
  echo file_get_contents($path);
});

So running phake dump index.php would run the dump task which processes any additional arguments internally. I understand that this might be an unwanted side-effect, but it certainly adds to a nicer syntax than the usual phake dump path=index.php.

jaz303 commented 10 years ago

Multiple task support is desirable; I use it frequently with rake/capistrano.

We could adopt the unix-y idiom of using a double-dash to separate user arguments from switches/flags. This would give us an officially sanctioned mechanism for passing positional arguments:

task('dump', function($app) {
  $dump = $app[0];
  echo file_get_contents($dump);
});

To invoke:

phake dump -- index.php

What do you think?

clue commented 10 years ago

Multiple task support is desirable

Turns out I was wrong. Phake does support running multiple tasks. So the provided example does work as expected and returns ab.

The Phakefile that led me to file this issue actually invoked a pcntl_exec() which does not return. My bad.

We could adopt the unix-y idiom of using a double-dash to separate user arguments [...]. What do you think?

Using a double dash makes perfect sense and would be a nice feature. Though I still think passing positional arguments without special syntax would still be even better. Anyway, I'll file a new ticket to keep track of this discussion.