You are here

function drush_schema_describe in Schema 6

Command callback for drush schema-describe.

File

./schema.drush.inc, line 65
Schema drush commands.

Code

function drush_schema_describe($module = NULL) {
  $schemas = drupal_get_schema_unprocessed($module);
  if (!empty($schemas)) {
    foreach ($schemas as $tablename => $table) {
      $rows = array();
      drush_print(str_repeat('-', 80));
      drush_print($tablename . ' - ' . $table['description']);
      drush_print(str_repeat('-', 80));
      $rows[] = array(
        'field',
        'description',
        'type',
      );
      foreach ($table['fields'] as $fieldname => $field) {
        $rows[] = array(
          $fieldname,
          $field['description'],
          $field['type'],
        );
      }
      drush_print_table($rows, TRUE);
    }
  }
  else {

    // Since no module was specified, show the user a list to choose from.
    module_load_all_includes('install');
    $modules = array();
    foreach (module_implements('schema') as $module_name) {
      $modules[$module_name] = $module_name;
    }
    $choice = drush_choice($modules, 'Enter a number to choose which schema to describe', '!key');
    if ($choice !== FALSE) {
      drush_schema_describe($choice);
    }
  }
}