<?php

namespace drunomics\Phapp\Commands;

use League\Container\ContainerAwareTrait;
use Robo\Common\IO;
use Robo\LoadAllTasks;
use Symfony\Component\Console\Question\ChoiceQuestion;

/**
 * Class ExecCommand.
 */
class ExecCommand {

  use ContainerAwareTrait;
  use LoadAllTasks;
  use IO;


  /**
   * Executes commands based on the environment.
   *
   * @command exec
   */
  public function execCommand($name) {
    $currentpath = realpath(getcwd());
    if ($strpos = strpos($currentpath, "vcs/web")) {
      $projectpath = substr($currentpath, 0, $strpos);
      $project = basename($projectpath);
      // Detect vagrant environment
      if (file_exists($projectpath . '.vagrant')) {
        $command = "docker exec " . $project . " " . $name;
      }
      else {
        // Use the wrapper script for drush.
        if ($name == "drush") {
          $command = $projectpath . "/vcs/web/drush.wrapper";
        }
        else {
          $command = $name;
        }
      }
      $this->_exec($command);
    }
     else {
      print("You need to be in the web directory to execute this command.\n");
    }
  }
}

<?php

namespace drunomics\Phapp\Commands;

use League\Container\ContainerAwareTrait;
use Robo\Common\IO;
use Robo\LoadAllTasks;
use Symfony\Component\Console\Question\ChoiceQuestion;

/**
 * Class ExecCommand.
 */
class ExecCommand {

  use ContainerAwareTrait;
  use LoadAllTasks;
  use IO;


  /**
   * Executes commands based on the environment.
   *
   * @param string $exec_command The command to execute.
   * @param string[] $arguments The command arguments.
   *
   * @command exec
   */
  public function execCommand($exec_command, array $arguments) {
    $currentpath = realpath(getcwd());
    if ($strpos = strpos($currentpath, "vcs/web")) {
      $projectpath = substr($currentpath, 0, $strpos);
      $project = basename($projectpath);
      // Detect vagrant environment
      if (file_exists($projectpath . '.vagrant')) {
        $exec_command = "docker exec " . $project . " " . $exec_command;
      }
      else {
        // Use the wrapper script for drush.
        if ($exec_command == "drush") {
          $exec_command = $projectpath . "/vcs/web/drush.wrapper";
        }
      }
      $this->_exec($exec_command . ' ' . implode(' ', $arguments));
    }
     else {
      print("You need to be in the web directory to execute this command.\n");
    }
  }
}

Allow multiple arguments to be passed to phapp exec.
INF-155: Allow multiple arguments to be passed to phapp exec.
