jigarius/drall

Unify the ExecDrush and ExecShell commands

Closed this issue · 3 comments

Motivation

  • A few versions ago, 2 commands were introduced: exec:shell and exec:drush.
  • The exec:drush command was used to ensure that we use the correct drush executable, i.e. the one in the project.
  • Thinking about it, this complicates the application by giving us more code to maintain
  • If we can unify these 2 commands, we can have drall exec ... in all cases, which is easier for the users as well and makes more sense because after all drush is nothing but a command just like any other.

Proposed solution

  • Remove exec:drush command in favor of exec:shell.
    • exec:drush can then be performed with: drall exec:shell drush @@site.local st
  • By default the drush executable detected by the system will be used.
  • If the user wants to force the Drush that's in vendor/bin/drush, they can write @@drush instead of drush?

Without doing this one first, most development effort will be double, i.e. once for exec:drush and once for exec:shell. So, I'm starting on this one first.

Having used this tool for around a year, now it is clear and proven that there is no need for 2 separate commands after all.

Currently when a user runs drall exec:drush ..., Drall detects and uses the project's drush version, i.e. ./vendor/bin/drall .... However, it seems like this is extra work for Drall and should be done by the user instead. For example:

# Run the drush instance that's in the global `$PATH`.
# If there's no global drush, the user should install Drush Launcher.
drall exec drush core:status

# Run the drush instance that's in the project.
drall exec ./vendor/bin/drush core:status

This way, Drall has less responsibility. Besides, if the user is running multiple drush commands, it won't be possible for Drall to easily replace drush with the project-specific Drush path. It's better that the user ensures drush can be executed correctly instead of Drall trying to solve that problem.

Here's what was done:

  • On 2.x, using anything other than drall exec and drall ex to execute commands throws a warning suggesting the use of drall exec.
  • On 3.x, the ExecDrushCommand and ExecShellCommand are combined into ExecCommand.