How to adapt the name of a custom Drush command? I saw the interesting answer to the question about "How can I get a list of content types with drush?", which starts like so:


  You can create a drush command named content-type-list.


But I wonder what it should look like if the command should be named something else, eg mijn-contenttypes-lijst (instead of content-type-list), and use drush drush mcl (instead of drush ctl)?

Some reasons why I may want to use another name:


Because it conflicts with something else in Drupal for which I already used content-type-list and/or ctl.
The command is hard to remember (eg because it's not in my native language), so I want to adapt it to another name.


What exactly would I have to change in the code included in that answer, which currently looks like so:

&lt;?php
/**
 * @file
 * Drush commands related to Content Types.
 */

/**
* Implements hook_drush_command().
*/
function drush_content_types_drush_command() {
  $items['content-type-list'] = array(
    'description' =&gt; dt("Show a list of available content types."),
    'aliases' =&gt; array('ctl'),
  );
  return $items;
}

/**
 * Callback for the content-type-list command.
 */
function drush_drush_content_types_content_type_list() {
  $content_types = array_keys(node_type_get_types());
  sort($content_types);

  drush_print(dt("Machine name"));
  drush_print(implode("\r\n", $content_types));
}


PS: I understand I can create aliases for it also (as shown in the linked answer), but that's not what my question is about. E.g. if I want a command that does something different.
You would have to change a couple of things:

/**
 * Implements hook_drush_command().
 */
function drush_content_types_drush_command() {
  $items['mijn-contenttypes-lijst'] = array(
    'description' =&gt; dt("Show a list of available content types."),
    'aliases' =&gt; array('mcl'),
  );
  return $items;
}


The array key under $items and the "aliases" value under that need changed. The array key is used to identify the callback to invoke when using the drush command or alias. The callback, for whatever reason, doesn't start with the command file prefix but rather starts with "drush" and then the command file prefix and then the array key listed above replacing the dashes with underscores. So the second (callback) function would look like...

/**
 * Callback for the content-type-list command.
 */
function drush_drush_content_types_mijn_contenttypes_lijst() {
  $content_types = array_keys(node_type_get_types());
  sort($content_types);

  drush_print(dt("Machine name"));
  drush_print(implode("\r\n", $content_types));
}


Making those changes should give you what you want. More information about creating your own drush commands can be found here: Command Authoring