Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call Drupal Console commands natively from Drush #1337

Closed
wants to merge 4 commits into from

Conversation

greg-1-anderson
Copy link
Member

In this PR, we build Drush command records for all Console commands, so that they can be displayed in Drush's help output, and executed.

  • Require Console in Drush's composer.json, so it is always available.
  • Run Console commands via Drush: drush @site x-generate-module.
  • Bootstrap Drush-style, using Console to create kernel and later bootstrap it.
  • Decide if we want to support recommending instead of requiring Console
  • Decide if we want commands to be generate:module or generate-module
  • Decide on a strategy to resolve conflicts between similarly-named or similarly-featured commands
  • Make Console return structured output to Drush, so that Drush-styled output formatters can be used.
  • Make a 1.0 stable release of Console, and bump the major version every time a breaking change is made.

This PR, while still early, is an exciting step forward, and meets many of the goals discussed in #88. It allows folks to write symfony console component commands, and call them from Drush utilizing Drush features (e.g. site aliases, shell aliases, command-specific options, etc.). In the future, the construction of the Symfony application object, currently done in an adapter file (consoleadapter.drush.inc) could instead become part of the core Drush bootstrap, and used natively by Drush commands.

…h command records for all Console commands, so that they can be displayed in Drush's help output, and executed. This allows us to run commands such as 'drush @Remote x-generate-module', and remotely run Console commands with a Drush alias.  Code is still rough at the moment.  Console commands are converted from 'generate:module' to 'x-generate-module' to match Drush command conventions without overlapping with existing Drush commands. This won't be the final transformation, but some discussion will be necessary before we can decide on what it should be.
…require ~0 instead of dev-master. Also, commit composer.lock to passify Travis.
@greg-1-anderson
Copy link
Member Author

Drat. I deliberately did not include composer.lock in the original PR, to avoid a huge number of irrelevant lines in the diff, but doing that caused Travis to have an existential crisis. So, I've added composer.lock to make the tests run -- sorry for the size of the diff.

…D before $application->run(), to prevent Drush from complaining about the call to exit().
@greg-1-anderson
Copy link
Member Author

I didn't need to worry about including composer.lock in the PR; github is smart enough to hide this file in the diff by default.

There are a couple of spurrious failures above, related to cloning the cck_signup project. Everything else is green; onward and upward.

@jhedstrom
Copy link
Member

I like that this is the 1337 PR 👍

@greg-1-anderson greg-1-anderson changed the title Include Drupal Console in Drush's composer.json file. Call Drupal Console commands natively from Drush Apr 16, 2015
@@ -30,7 +30,8 @@
"d11wtq/boris": "~1.0",
"symfony/yaml": "~2.2",
"symfony/var-dumper": "2.6.3",
"pear/console_table": "~1.2.0"
"pear/console_table": "~1.2.0",
"drupal/console": "~0"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask why is this required? I think it should be optional or recommended.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Drupal Console is required, then it gives us a mechanism to use its code to start migrating Drush commands to the Symfony console. At the moment, though, this PR is just a proof-of-concept. At first, there won't be any Drush commands that require Drupal Console, so we could certainly start off with this as a recommended package.

…e kernel object during the bootstrap configuration phase, and then bootstrap the kernel in the bootstrap full phase.
@weitzman
Copy link
Member

Myself and Jesus from Drupal Console plan to discuss this PR and general collaboration approach during upcoming Drupalcon (mid May). I'll post here after that discussion.

@webchick
Copy link

Not sure exactly where best to cross-link this, but trying this one (nice issue ID btw :D).

Note that there's an RTBC issue in the Drupal core queue at https://www.drupal.org/node/2493807 to add Symfony Console to D8 core. This is soft-blocking the critical issue about testing 8.x -> 8.x upgrade paths at https://www.drupal.org/node/2447573 which is why it's being considered at this late date for 8.0.0.

Not sure if this helps or hurts your efforts but maybe chime in there if you have thoughts!

@chx
Copy link
Contributor

chx commented Sep 25, 2015

What I said in https://www.drupal.org/node/2391219 stands: console shouldn't exist because it will force contrib authors to ship console AND drush integration both. As I mentioned there, core hardwires certain things to stop such idiocy -- modules can only ship default extension templates so that noone can demand from contrib authors to ship several templates. Configuration install storage is no longer a service, enforcing everyone to ship YAML configuration. Alas, the project has no tech leadership to enforce such splinter does not happen outside of core. Short of that and short of the webmasters having two brain cells to shut the console project down, this is an absolute critical so that when people file issues to ship console integration the contrib authors can won't fix them and point to drush integration and that's it.

@greg-1-anderson
Copy link
Member Author

Well, I admit it is kind of regrettable that there are two tools here, but the current state of affairs being what they are, most folks will not be able to help but to use both Drush and Drupal Console when working with Drupal 8. This is going to cause some problems in contrib, but the problem is just going to be that contrib authors are going to have to decide whether to use Drush or Console to implement their cli tools; no one is going to need to write a Drush interface and a Console interface.

Still, there are lots of reasons why we should merge Console and Drush. The main ones are:

  • There should be one cli bootstrap for D8. It's actually a lot of work to get this right, and this work is currently duplicated. (We made the Console bootstrap better when sprinting on this issue at Pantheon, and it has been improved further since then.)
  • No one wants to maintain two sets of site aliases. Drush has some pretty nifty remote command handling features; Console is just starting on remote execution, and it will be a big hassle for everyone if it works differently than Drush.
  • Drush has done a lot of work to eliminate the "dependency hell" problems that can arise with Composer-managed Drupal projects. Console should leverage this work, not duplicate it -- or ignore it. Console has been getting along just fine ignoring the problem, and rev-locking one version of Console to one version of Drupal, but this won't work well once people start using more than one version of Drupal 8 at a time.

The solution here isn't to "stop Console". We all owe a lot to the Console project. They have made some really useful tools, and the decision to decouple allowed them to make faster progress than if they had fixed the problems in Drush. As I have mentioned before, we have had the idea / desire to use the Symfony Console component in Drush since before the Drupal Console existed, but no one has been available to finish the hard work that would make that possible. This issue has come a long way to making that a reality, but it is unclear whether, in the end, we as a community are going to do the right thing, or whether we're going to keep doing the easier thing, and make small independent changes to each project. I think that in the beginning, it was the right decision to work independently, but only because we lacked enough volunteer hours to do the hard work, and we needed the capabilities that could be easily provided to the community by making a separate Symfony-based tool. The time has come now, though, to start paying down some of the technical debt, and work on better integration for the tools.

There are two more points I want to make in closing:

  1. This issue is not the only way forward. We can also meet some of our goals by creating separate libraries used by both tools. I have started some work in this direction at https://github.com/drush-ops/drush-aliases.
  2. Even if we do merge Drush + Drupal Console into a single tool, we are still going to have both the legacy Drush command dispatcher, and the Symfony command dispatcher, and contrib authors will need to choose which one they use.

So, fragmentation is inevitable. The solution is not to try to stop folks from writing awesome tools, but rather to do more of the less-glamorous maintenance work to keep them working well together.

We're going to be sprinting at BADCamp; anyone who wants to pitch in is welcome to join us.

@develCuy
Copy link

@greg-1-anderson ++

The spirit of Free Software is to let authors contribute with freedom, we should not read (yes, I'm using "should" @chx) "don't duplicate efforts" literally. I prefer to say: "don't waste efforts". Should we afford to rewrite Drush for Drupal 8? Drush was a fantastic tool but now is time for a new project: DrupalConsole. Letting Drush integrate with the future is an smart move, less hassle IMHO.

My 2c.

PS: http://cgit.drupalcode.org/drush/commit/?id=92611ecbcbfe7f6722882bcfa50e6cbcc915c2a5

@mglaman
Copy link
Contributor

mglaman commented Sep 27, 2015

I think this is a great move forward. Console supports calling Drush, Drush supports calling Console. Having two tools is a bit maddening, but it's better to piggyback one another than work on the same thing. Drush doesn't provide code scaffolding and Drush does many things Console does not.

Fragmentation is a repercussion of progress. At least efforts are being made to simplify the future and abstract components into shared libraries.

@greg-1-anderson++

@greg-1-anderson
Copy link
Member Author

See also #2103

@weitzman
Copy link
Member

weitzman commented Aug 5, 2016

Drush's master branch can now execute Symfony commands. I think thats as close as we are going to get on this one.

@weitzman weitzman closed this Aug 5, 2016
@weitzman weitzman deleted the drush-console branch August 5, 2016 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants