function drush_environment_table_lib

6.x environment.inc drush_environment_table_lib()
5.x environment.inc drush_environment_table_lib()
1 call to drush_environment_table_lib()
_drush_bootstrap_drush_validate in includes/bootstrap.inc
Validate that Drush is running in a suitable environment.

File

includes/environment.inc, line 134
Functions used by drush to query the environment and setting the current configuration.

Code

function drush_environment_table_lib() {
  // Try using the PEAR installed version of Console_Table.
  $tablefile = 'Console/Table.php';
  if (@file_get_contents($tablefile, FILE_USE_INCLUDE_PATH) === FALSE) {
    $lib = drush_get_option('lib', DRUSH_BASE_PATH . '/lib');
    $tablefile = $lib . '/Console_Table-' . DRUSH_TABLE_VERSION . '/Table.php';
    // If it is not already present, download Console Table.
    if (!drush_file_not_empty($tablefile)) {
      // Attempt to remove the old Console Table file, from the legacy location.
      // TODO: Remove this (and associated .git.ignore) in Drush 6.x.
      $tablefile_legacy = DRUSH_BASE_PATH . '/includes/table.inc';
      if (drush_file_not_empty($tablefile_legacy)) {
        drush_op('unlink', $tablefile_legacy);
      }

      // Download and extract Console_Table, and confirm success.
      if (drush_lib_fetch(CONSOLE_TABLE_BASE_URL . DRUSH_TABLE_VERSION . '.tar.gz')) {
        // Remove unneccessary package.xml file which ends up in /lib.
        drush_op('unlink', $lib . '/package.xml');
      }
      if (!drush_file_not_empty($tablefile)) {
        return drush_bootstrap_error('DRUSH_TABLES_LIB_NOT_FOUND', dt("Drush needs a copy of the PEAR Console_Table library in order to function, and the attempt to download this file automatically failed. To continue you will need to download the !version package from http://pear.php.net/package/Console_Table, extract it into !lib directory, such that Table.php exists at !tablefile.", array('!version' => DRUSH_TABLE_VERSION, '!tablefile' => $tablefile, '!lib' => $lib)));
      }
    }
  }
  require_once $tablefile;
}