Write drush integration for your module
dereine — 12. Mai 2010 - 5:50
Everyone loves Drush
Wouldn't it be cool if more modules would have a drush integration?
Here is one short introduction how to do it.
- Create a modulename.drush.inc in your modules dir
- Implement hook_drush_command:
/<strong>
* Implementation of hook_drush_command().
*/
function mongodb_drush_command() {$items['mongodb-connect'] = array(
'description' => 'A string for connecting to the mongodb.',
// alternatives
/</strong>
* DRUSH_BOOTSTRAP_DRUSH
* DRUSH_BOOTSTRAP_DRUPAL_ROOT
* DRUSH_BOOTSTRAP_DRUPAL_SITE
* DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION
* DRUSH_BOOTSTRAP_DRUPAL_DATABASE
* DRUSH_BOOTSTRAP_DRUPAL_FULL
* DRUSH_BOOTSTRAP_DRUPAL_LOGIN
*/
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION,
// 'options' => $options,
'arguments' => array(
'alias' => 'The connection',
),
);
...
return $items;
} - Implement hook_drush_help
/**
* Implementation of hook_drush_help().
*/
function mongodb_drush_help($section) {
switch ($section) {
case 'drush:mongodb-conf':
return dt('Show database connection details.'); - Implement the command. The nameing convention is drush_$str_replace('-', '_', COMMAND_KEY)$, for example
/**
* Drush callback; Return the connect string.
*/
function drush_mongodb_connect($alias = 'default') {
$command = _drush_mongodb_connect($alias);
drush_print($command);
}
That's it, provide some love for your drupal module.



Pingback
Twitter Trackbacks for Write drush integration for your mod (nicht überprüft) — 12. Mai 2010 - 9:42[...] Write drush integration for your module | freeblogger.org freeblogger.org/blog/dereine/2010-05-12-write-drush-integration-your-module – view page – cached Wouldn't it be cool if more modules would have a drush integration? Here is one short introduction how to do it. Tweets about this link Topsy.Data.Twitter.User['gazwal'] = {"photo":"http://a3.twimg.com/profile_images/200996499/avatar-85-85-gazwal_normal.png","url":"http://twitter.com/gazwal","nick":"gazwal"}; gazwalInfluential: “+1 RT @drupalcenter: Freeblogger: Write drush integration for your module: Everyone loves Drush Wouldn't… http://bit.ly/bzgeiX #drupal ” 34 minutes ago view tweet retweet Topsy.Data.Twitter.User['drupalcenter'] = {"photo":"http://a1.twimg.com/profile_images/703098302/druplicon.small_normal.png","url":"http://twitter.com/drupalcenter","nick":"drupalcenter"}; drupalcenter: “Freeblogger: Write drush integration for your module: Everyone loves Drush Wouldn't… http://goo.gl/fb/5L1TF #drupal ” 2 hours ago view tweet retweet Filter tweets [...]
Kommentar hinzufügen