You are here

function rdfx_drush_arc2_download in RDF Extensions 7.2

Example drush command callback.

This is where the action takes place.

In this function, all of Drupals API is (usually) available, including any functions you have added in your own modules/themes.

To print something to the terminal window, use drush_print().

1 call to rdfx_drush_arc2_download()
drush_rdfx_post_pm_enable in drush/rdfx.drush.inc
Implements drush_MODULE_post_COMMAND().
1 string reference to 'rdfx_drush_arc2_download'
rdfx_drush_command in drush/rdfx.drush.inc
Implementation of hook_drush_command().

File

drush/rdfx.drush.inc, line 67
drush integration for rdfx.

Code

function rdfx_drush_arc2_download() {
  $args = func_get_args();
  if ($args[0]) {
    $path = $args[0];
  }
  else {
    $path = drush_get_context('DRUSH_DRUPAL_ROOT');
    if (module_exists('libraries')) {
      $path .= '/' . libraries_get_path('ARC2');
    }
    else {
      $path .= '/' . drupal_get_path('module', 'rdfx') . '/vendor';
    }
  }

  // Create the path if it does not exist yet.
  if (!is_dir($path)) {
    drush_mkdir($path);
  }
  if (is_dir($path . '/arc')) {
    drush_log('ARC2 already present. No download required.', 'ok');
  }
  elseif (drush_op('chdir', $path) && drush_shell_exec('wget -O arc.tar.gz http://github.com/semsol/arc2/tarball/master') && drush_shell_exec('tar zxvf arc.tar.gz') && drush_shell_exec('mv semsol-arc2-* arc') && drush_shell_exec('rm arc.tar.gz')) {
    drush_log(dt('The latest ARC2 library has been downloaded to @path', array(
      '@path' => $path,
    )), 'success');
  }
  else {
    drush_log(dt('Drush was unable to download the ARC2 library to @path', array(
      '@path' => $path,
    )), 'error');
  }
}