Hi,

I think it would be nice to be able to disable the contribs only via a simple drush_mm command.

I wrote a working and tested prototype in bash (

attached at http://drupal.org/node/348914 - Drush MM docs page.

direct link - http://drupal.org/files/drlist_contribs.sh_.txt ) - it lists only enabled contribs - so it is easy to do a

drush mm disable/enable on its output...

What steps do we need to get a list-contribs command?

Am I welcome to do that?

Comments

clemens.tolboom’s picture

I guess I could change the behaviour of drush mm list by either adding a param so drush mm list enabled could work or just when in --verbose mode list all modules.

Please give some feedback :-)

rsvelko’s picture

I spent some time thinking on the smartest (both in user experience and code-elegance) way to do this, so here it is:

1. I modified the _drush_mm_list_modules function: (have not touched the 'list' array - cause it may be used somewhere else and I did not wish to mess with it )

so now the func is : (diff below, after it)


function _drush_mm_list_modules( $modules_info, $return_list=FALSE) {
  $list = array();
  
//  print_r($modules_info);
  
  foreach ($modules_info as $key => $value) {
    if ($value['name']) {
      if (DRUSH_VERBOSE) {
        $list[ $value['status']][]=  $key .' ('. $value['version'] .')';
      }
      else {
        $list[ $value['status']][]=  $key;
        
        if (  $value['status']  == 1 && 
              $value['package'] != "Core - optional" &&
              $value['package'] != "Core - required"
            ) { $list_enabled_contribs[] = $key; }
        
        $list_by_package = "";
        
      }
    } 
    else {
      if (isset($value['status'])) {
        $list['error'][]= $key;
      }
      else {
        $list['missing'][]= $key;
      }
    }
  }
  
  sort( $list['error']);
  sort( $list['missing']);
  sort( $list[0]);
  sort( $list[1]);
  if ($return_list) return $list;
  if (count($list['error'])) {
    echo "According to the system table available modules but not installed!\n";
    echo "  ERROR: ". implode( ", ", $list['error']) ."\n\n";
  }

  if (count($list['missing'])) {
    echo "missing: ". implode( " ", $list['missing']) ."\n\n";
  }
  echo "enabled: ". implode( " ", $list[1]) ."\n\n";
  echo "disabled: ". implode( " ", $list[0]) ."\n\n";

  sort( $list_enabled_contribs);
  echo "enabled contribs: ". implode( " ", $list_enabled_contribs) ."\n\n";
  echo "============
  
  To get all enabled/disabled modules from a given project/package just give its name as an argument to 'drush mm list'.
  Examples:
  
  drush mm list Development - lists all modules from package Development (they have 'package = Development' in their .info file)
  drush mm list devel - lists all modules with 'project = \"devel\"' in their .info file
  
  NOTE: 'Devel', 'evelopment' and 'evel' would work too - 'evel' outputting both package and project listings...
  ";
}


And a diff:


diff -r sites/all/modules/drush_mm/drush_mm.inc ../umed/sites/all/modules/drush_mm/drush_mm.inc
50,51d49
< //  print_r($modules_info);
<
59,66d56
<
<         if (  $value['status']  == 1 &&
<               $value['package'] != "Core - optional" &&
<               $value['package'] != "Core - required"
<             ) { $list_enabled_contribs[] = $key; }
<
<         $list_by_package = "";
<
94,103d83
<
<   sort( $list_enabled_contribs);
<   echo "enabled contribs: ". implode( " ", $list_enabled_contribs) ."\n\n";
<   echo "============
<
<   To get all enabled/disabled modules from a given project/package just give its name as an argument to 'drush mm list'.
<   Examples:
<
<   drush mm list Development - lists all modules from package Development (they have 'package = Development' in their .info file)
<   drush mm list devel - lists all modules with 'project = \"devel\"' in their .info file
105,106d84
<   NOTE: 'Devel', 'evelopment' and 'evel' would work too - 'evel' outputting both package and project listings...
<   ";


And the output as of now:


webmaster@velkosrv:/var/www/public_html/jivdom$ dr mm list
According to the system table available modules but not installed!
  ERROR: messaging_private

missing: notifications privatemsg simpletest sms twitter

enabled: admin_menu aggregator block blog book calendar collapsiblock color comment contact content date date_api date_timezone dblog drush drush_mm drush_pm drush_pm_wget drush_sql drush_tools fieldgroup filter forum help imageapi jcarousel jstools menu menu_html messaging messaging_mime_mail mibbit_irc mimemail moduleinfo nice_menus node number optionwidgets path pathauto php poll poormanscron profile search statistics syslog system taxonomy teleport text token token_actions tracker trigger update upload user views views_ui

disabled: blogapi calendar_ical content_copy content_permissions date_copy date_php4 date_popup date_repeat devel devel_generate devel_node_access devel_themer drupalforfirebug drupalforfirebug_preprocess drush_pm_cvs drush_pm_svn drush_simpletest imageapi_gd imageapi_imagemagick jcalendar locale macro messaging_debug messaging_mail messaging_notify messaging_phpmailer messaging_privatemsg messaging_simple messaging_sms messaging_twitter module_builder nodereference openid performance ping throttle translation userreference views_export

enabled contribs: admin_menu calendar collapsiblock content date date_api date_timezone drush drush_mm drush_pm drush_pm_wget drush_sql drush_tools fieldgroup imageapi jcarousel jstools menu_html messaging messaging_mime_mail mibbit_irc mimemail moduleinfo nice_menus number optionwidgets pathauto poormanscron teleport text token token_actions views views_ui

============

  To get all enabled/disabled modules from a given project/package just give its name as an argument to 'drush mm list'.
  Examples:

  drush mm list Development - lists all modules from package Development (they have 'package = Development' in their .info file)
  drush mm list devel - lists all modules with 'project = "devel"' in their .info file

  NOTE: 'Devel', 'evelopment' and 'evel' would work too - 'evel' outputting both package and project listings...

Mark the last part... enabled contribs are listed and a little help text printed... The text is meant for clemens to read and understand where I am taking us... It can be removed from the listing function...

As I see it just a list of enabled and disabled is not so important to the user of drush_mm.

A more interesting thing is
- "Is content_access enabled"
- or even "Is that 'access' or something module enabled?"
- or the usual 6.x->6.y question "How on earth am I supposed to disable and then re-enable those 30+ modules scattered acrross my admin/build/modules page ?!? "

So I propose we show the user enabled contribs (and maybe disabled?) by default and a wildcard capable per package/project listing on demand - as an additional argument to drush mm list (see echo-ed help text above )

That should do it all!

Opinions?

Greets.

Vladimir, Rousse, Bulgaria (and Vienna, Austria).

rsvelko’s picture

This way it will be an intuitive command - no additional complicated syntax.

rsvelko’s picture

Title: getting drlist_contribs.sh_.txt into a drush_mm command » drush_mm list command new features - list contribs and Co

the part with listing contribs is done by me above. What about the other features - how would we extend mm list ? Where to look at and how to do it most gracefully? Clemens?

clemens.tolboom’s picture

Assigned: Unassigned » clemens.tolboom

Great work ... Nicely documented ... hope to implement this soon.

rsvelko’s picture

Some progress on that ?

If you have some 1-2 hours these days we can make a mini "over the web" sprint? I am available at every time/hour in the next 5 days - email me via contact form if interested.

clemens.tolboom’s picture

I'd love to spent some time on your improvements ... hope to find it :(

I'm most of the time on irc so we could chat a little. And maybe solve this nice improvement :)

clemens.tolboom’s picture

Just another note: As I'm doing drush_sm at the same time where I use subcommands like list export and import maybe we could use export and import for this improvement?

clemens.tolboom’s picture

Just a note ... the filtering on Core modules is as simple as checking the module path DRUPAL_ROOT/modules right?

I have to check this with drush but maybe a switch like --skip-core would do the interfacing

drush --skip-core mm list
clemens.tolboom’s picture

Status: Active » Postponed (maintainer needs more info)

In adapting drush_sm to the latest version of drush 2.x I introduced some parameters and an option.

For this issue I will introduce a few options and parameters

--skip-core
--package=devel ?

and parameters?

Do we need more?

rsvelko’s picture

There are 2 tasks here:
1. --skip-core
2. list all modules that belong to a certain project/package (I forgot the difference between the two if any) or are named "devel" for example...

So - 1. is solved with this option introduced
and 2. - with the --package option (my personal opinion is that "drush mm list name" is better than "drush mm list --package name" ... If we write good docs it seems nicer(=shorter). )

rsvelko’s picture

about 2. - I need a wildcard implied by default - like bash's grep

so "eve" would match devel for example... with no need to write "*eve*" ...

puya’s picture

So, is this functionality (listing enabled contrib modules) committed to drush_mm or drush_sm or drush itself? or is it still a script?

clemens.tolboom’s picture

This feature is on my time restricted list of tasks ... so in the near future for drush_mm :)

clemens.tolboom’s picture

Status: Postponed (maintainer needs more info) » Active

Hmmm ... I somehow missed that all info is at hand.

[update] => Array
        (
            [name] => Update status
            [description] => Checks the status of available updates for Drupal and your installed modules and themes.
            [version] => 6.16
            [package] => Core - optional
            [core] => 6.x
            [project] => drupal
            [datestamp] => 1267662008
            [dependencies] => 
        )

[upload] => Array
        (
            [name] => Upload
            [description] => Allows users to upload and attach files to content.
            [package] => Core - optional
            [version] => 6.16
            [core] => 6.x
            [project] => drupal
            [datestamp] => 1267662008
            [dependencies] => 
        )

So for now I have to fiddle out how those args work.

puya’s picture

subscribing

clemens.tolboom’s picture

Status: Active » Closed (won't fix)

The module became obsolete for drupal 7. See project page for the reasons why.

drush has this nice command drush pml --no-core --status=enabled