It would be nice to have a command that could list available container services. We can filter these much like vget does, and also sort them.

Should be pretty simple to do.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damiankloip’s picture

FileSize
1.83 KB
damiankloip’s picture

Issue tags: +Needs tests

If this idea flies, I can write some tests.

Btw, using the output engine stuff is awesome!

moshe weitzman’s picture

Project: Drush » Devel
Version: 8.x-6.x-dev » 8.x-1.x-dev
Component: Core Commands » drush

Is there a reason why they should ever be unsorted?

I put the event listing command in devel, and i think this is similar. So, moving to devel project. I know that some folks won't like this decision but drush can't carry all the stuff that folks want to do with drupal. Devel exists for a reason.

damiankloip’s picture

I guess there is no reason why you would want that unsorted, I can remove that option.

Also, I think moving this to devel is a great idea. I'm all for it. I didn't actually think about that. Agree that everything can't live in the drush codebase.

damiankloip’s picture

Assigned: Unassigned » damiankloip
salvis’s picture

I'd love to see this in the Devel GUI, too.

dawehner’s picture

+++ b/commands/core/core.drush.incundefined
@@ -1237,3 +1260,25 @@ function drush_core_execute() {
+  $container = Drupal::getContainer();
...
+  if (empty($services)) {

Maybe we should also check for an empty container, for some reasons? No idea, though I can't imagine how there could be no services, if there is a container and a full bootstrap.

Just wondering whether there are some thoughts about dependency injection in drush :)

damiankloip’s picture

FileSize
1.85 KB

Ok, I have rerolled for devel instead of core drush, removed the sort option, and added a check for the container.

damiankloip’s picture

FileSize
1.79 KB

Sorry, wrong patch.

damiankloip’s picture

Do we want to use if($container = Drupal::getContainer()) {...} syntax instead? I don't mind, I guess it's all down to code style preferences.

dawehner’s picture

I don't mind either, it's just that these checks feels unneeded. Shouldn't we assume that if a full boostrap of drupal is done, it should work everything as expected?

+++ b/devel.drush.incundefined
@@ -244,3 +266,28 @@ function _drush_devel_print_function($file, $start_line, $end_line) {
+  if (isset($prefix)) {
+    $services = preg_grep("/$prefix/", $services);
+  }

Should we return something special, if there is no services with a certain prefix, like trigger an error?

damiankloip’s picture

FileSize
0 bytes

How about we just move the check for services below the prefix matching?

I feel we should leave the container check in, if someone has really broken their D8 installation this may help them at some point? If not, I'm happy to remove this too.

damiankloip’s picture

FileSize
1.79 KB

Oops, soory. a real patch is usually helpful.

dawehner’s picture

Status: Needs review » Needs work
+++ b/devel.drush.incundefined
@@ -244,3 +266,28 @@ function _drush_devel_print_function($file, $start_line, $end_line) {
+  return sort($services);

PHP is so cool, that it doesn't need to return the sorted array if you sort :)

damiankloip’s picture

Status: Needs work » Needs review
FileSize
1.81 KB

Thanks dawehner! that will not return us any services :)

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Awesome!

dawehner’s picture

#15: 1950930-15.patch queued for re-testing.

damiankloip’s picture

FileSize
515 bytes
1.81 KB

@amateescu spotted an extra space in the format description. Minor :)

moshe weitzman’s picture

Status: Reviewed & tested by the community » Needs work

Some command like this (e.g. core-config) will provide a choice menu when no argument is passed. The user then picks the service they care about and detail is shown. IMO thats better UX.

Is it really an error if no services are found. Instead use drush_log('No services found', 'ok').

damiankloip’s picture

Status: Needs work » Needs review
FileSize
1.81 KB

Made that change for drush_log. We talked about this on IRC, and think the actual implementation is good.

pcambra’s picture

Status: Needs review » Active

Committed the drush part in #20 to the D8 branch, it'd be great to have an UI for this as well.

moshe weitzman’s picture

Title: Add a core command to list container services » Add a core command to list container services (needs UI)
Issue summary: View changes
willzyx’s picture

Status: Active » Needs review
FileSize
3.67 KB

First try for the UI part

jibran’s picture

willzyx’s picture

@jibran maybe I'm wrong but I do not think the issues are related.. Also the drush part of this issue has already been committed (see 9f4c384); that is left to do is to create the UI

lussoluca’s picture

Webprofiler provides an UI for container services: We can try to extract more info or we can close this issue.

moshe weitzman’s picture

Status: Needs review » Fixed

OK, lets close this. Feature requests can be new follow-up issues.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.