"Refreshes a feed based on its schedule.", 'arguments' => array( 'feed-name' => 'The name of the feed importer that will be refreshed. Mandatory.', ), ); $items['feeds-queue'] = array( 'description' => "Adds a scheduled feed to the drupal_queue.", 'arguments' => array( 'feed-name' => 'The name of the feed importer that will be added to the queue. Mandatory.', ), ); $items['feeds-config'] = array( 'description' => "Displays all active importers or displays the config of a given importer (passed as arg).", ); return $items; } /** * Implementation of hook_drush_help(). * * @param * A string with the help section (prepend with 'drush:') * * @return * A string with the help text for your command. */ function feeds_drush_help($section) { switch ($section) { case 'drush:feeds-refresh': return dt("Refreshes a feed based on its schedule."); case 'drush:feeds-queue': return dt("Adds a scheduled feed to the drupal_queue."); case 'drush:feeds-config': return dt("Displays all active importers or displays the config of a given importer (passed as arg)."); } } /** * Refresh a given feed_name based on its schedule. * The feed will not be refresh if it's not scheduled. * * @param string $feed_name */ function drush_feeds_cron($feed_name) { if (!isset($feed_name) || $feed_name == "") { print 'The importer feed_name is required.'; return FALSE; } feeds_scheduler()->cron($feed_name, 'feeds_scheduler_drush', TRUE); } /** * Add a scheduled feed to the drupal_queue. * * @param string $feed_name */ function drush_feeds_queue($feed_name) { if (!isset($feed_name) || $feed_name == "") { print 'The importer feed_name is required.'; return FALSE; } if (module_exists('drupal_queue')) { feeds_scheduler()->cron($feed_name); } else { drush_print('Drupal_queue module is required for this feature.'); } } /** * Display the config of a given importer. * * @param string $feed_name */ function drush_feeds_config() { $args = func_get_args(); $feed_name = $args[0]; if (!isset($feed_name) || $feed_name == "") { $importers = feeds_importer_load_all(); drush_print("\nHere is a list of active importers:\n"); foreach ($importers as $importer) { drush_print($importer->config['name'] . " ({$importer->id})"); drush_print(" - " . $importer->config['description']); drush_print(" * " . $importer->config['fetcher']['plugin_key']); drush_print(" * " . $importer->config['parser']['plugin_key']); drush_print(" * " . $importer->config['processor']['plugin_key']); drush_print("\n\n"); } return FALSE; } $sql = "SELECT id, feed_nid, config, source FROM {feeds_source} WHERE id = '%s'"; $result = db_query_range($sql, $feed_name, 0, 1); $feed_info = db_fetch_array($result); if ($feed_info) { $importer = feeds_importer($feed_info['id']); drush_print($importer->config['name']); drush_print(" - " . $importer->config['description']); drush_print(" * " . $importer->config['fetcher']['plugin_key']); drush_print(" * " . $importer->config['parser']['plugin_key']); drush_print(" * " . $importer->config['processor']['plugin_key']); drush_print("\nFeed nid:"); print_r(unserialize($feed_info['feed_nid'])); drush_print("\nSource:"); print_r(unserialize($feed_info['source'])); drush_print("\nConfig:"); print_r(unserialize($feed_info['config'])); } else { drush_print("The importer '$feed_name' does not exist."); } return; }