`drush statusmodules` displays a list of all module's name, status and description. If `--pipe` option is given it will list the names of enabled modules.

A better approach could be to a option like this `--status=enabled|disabled` and make --pipe behave the same as no pipe.

CommentFileSizeAuthor
#10 679020.patch7.19 KBjonhattan
#5 679020.patch7.11 KBjonhattan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

people wanted a form that they can easily parse and reuse - thus the space delimited in --pipe. i do think enabled/disabled/uninstalled are helpful.

jonhattan’s picture

So the proposal here could be to use the new name for statusmodules (pm-status or pm-list as suggested in #678574-12: Add "pm-" namespace to all of the pm commands) extending it to list themes (code already here #530780: drush commands to administer themes) and perhaps profiles AND add a two new options:

* --project-type=modules|themes|profiles
* --status=any|enabled|disabled|uninstalled (some choices not applicable depending on the project-type).
* make --pipe work in concordance with --status

moshe weitzman’s picture

i think we should provide filters to the extent that grep is not a sufficient solution. i'm willing to relax that, if people think explicit options is significantly more friendly.

jonhattan’s picture

Title: `statusmodules --pipe` only list enabled modules » Extend `statusmodules` to list modules, themes and profiles and filter by project status (enabled|disabled|uninstalled...)
jonhattan’s picture

Title: Extend `statusmodules` to list modules, themes and profiles and filter by project status (enabled|disabled|uninstalled...) » Extend `pm-list` to list modules, themes and profiles and filter by project status (enabled|disabled|uninstalled...)
Status: Active » Needs review
FileSize
7.11 KB

patch with options proposed in #2.

Internals:
1. new function drush_get_projects(). Used by pm-list and pm-info. To be used by pm-enable/disable.
2. new function drush_get_project_status() returns enabled/disabled/uninstalled. Used by both pm-list and pm-info. Can be easily extended to support "missing" with naught101's code in #496008: More useful info in statusmodules.

Feature request: provide options for module packages. not applicable for themes... or use base theme as package info¿?. related: #654682: drush statusmodule --package: Package column and grouping for the statusmodules list.

ps. patch also fix minor things for pm-info

jonhattan’s picture

new patch with a fix for --pipe.

note the listings don't have a column for given filter options.

screenshots:

$ drush pm-list --type=theme
 Name                                            Status    Version     
 Garland (garland)                               Enabled   7.x-dev     
 Seven (seven)                                   Enabled   7.x-dev     
 Stark (stark)                                   Enabled   7.x-dev     
 Update test base theme (update_test_basetheme)  Disabled  7.x-dev     
 Update test subtheme (update_test_subtheme)     Disabled  7.x-dev     
 Zen (zen)                                       Enabled   7.x-3.x-dev 

$drush pm-list --type=theme --pipe
garland seven stark update_test_basetheme update_test_subtheme zen

$ drush pm-list --type=theme --status=enabled
 Name               Version     
 Garland (garland)  7.x-dev     
 Seven (seven)      7.x-dev     
 Stark (stark)      7.x-dev     
 Zen (zen)          7.x-3.x-dev 

$ drush pm-list --type=theme --status=enabled --pipe
garland seven stark zen

$ drush pm-list --type=module --status=enabled
 Name                                   Version     
 Administration menu (admin_menu)       7.x-3.x-dev 
 Block (block)                          7.x-dev     
 Contextual links (contextual)          7.x-dev     
 Dashboard (dashboard)                  7.x-dev     
 Devel (devel)                          7.x-1.x-dev 
 Field (field)                          7.x-dev     
 Field SQL storage (field_sql_storage)  7.x-dev     
 Field UI (field_ui)                    7.x-dev     
 Help (help)                            7.x-dev     
 Menu (menu)                            7.x-dev     
 Node (node)                            7.x-dev     
 Number (number)                        7.x-dev     
 Overlay (overlay)                      7.x-dev     
 Search (search)                        7.x-dev     
 Shortcut (shortcut)                    7.x-dev     
 System (system)                        7.x-dev     
 Taxonomy (taxonomy)                    7.x-dev     
 Text (text)                            7.x-dev     
 Toolbar (toolbar)                      7.x-dev     
 User (user)                            7.x-dev     

$ drush pm-list --type=module --status=enabled --pipe
admin_menu block contextual dashboard devel field field_sql_storage field_ui help menu node number overlay search shortcut system taxonomy text toolbar user
moshe weitzman’s picture

Status: Needs review » Needs work

Code looks good.

On drupal 7, there are 'hidden' projects which should not appear in pm-list.

I think Uninstalled is pretty confusing for projects you never installed. If we can't distinguish, I guess we should say nothing. Sorry about that.

I'd like some more input about these filters. I guess I am OK with them. I do note that you can pretty easily accomplish both filters with grep.

jonhattan’s picture

From a developer viewpoint perhaps hidden should appear in the listing. I have no preferences here.

Uninstalled status is a mix of enabled=0 and schema_version=-1. There's no way to differentiate uninstalled / never installed beyond some heuristics (weight != 0 or other garbage in system table --not always available). The message can be "not installed". I think it is of interest because a disabled module is still a installed one. Although it can be confusing for a end user. No special preferences neither.

filters and grep: filters are user friendly and of special interest in conjunction with --pipe. Think of

drush pm-uninstall `drush pm-list --pipe --type=module --status=disabled`

filters can also be easily extended to support more than one option: --status=disabled|uninstalled.

moshe weitzman’s picture

OK, lets keep the filters and remove hidden from D7. I think very few devs want to see those hidden modules. drupal core ships with a boatload of them.

The uninstall page in drupal seems to unambigously know what modules are eligible for uninstall. Thats pretty related to distinguishing never installed from uninstalled.

jonhattan’s picture

FileSize
7.19 KB

Modules pending uninstall are those with enabled=0 and schema_version > -1 and define hook_uninstall. Once uninstalled, no way to know if it was installed any time in the past or is a pristine one afaics. I've changed uninstalled to not installed.

Also hidden modules are out in this patch.

jonhattan’s picture

Status: Needs work » Needs review
moshe weitzman’s picture

Status: Needs review » Fixed

Committed. Thanks.

Status: Fixed » Closed (fixed)

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