diff --git a/feeds.drush.inc b/feeds.drush.inc index 5d003ee..484a411 100644 --- a/feeds.drush.inc +++ b/feeds.drush.inc @@ -7,33 +7,26 @@ /** * Implements hook_drush_command(). - * - * @see drush_parse_command() for a list of recognized keys. - * - * @return array - * An associative array describing your command(s). */ function feeds_drush_command() { $items = array(); $items['feeds-list-importers'] = array( - 'description' => 'Displays the configs of all importers.', - 'examples' => array( - 'drush feeds-list', - ), + 'description' => 'Get a list of all Feeds importers in the system.', ); $items['feeds-list-feeds'] = array( - 'description' => 'Displays all instances of all Feeds of a given importer (passed as arg).', + 'description' => 'List all feed sources.', 'arguments' => array( 'importer' => 'The name of the Feeds importer whose instances will be listed. Optional.', ), 'examples' => array( 'drush feeds-list-feeds' => 'List all instances of all feeds.', - 'drush feeds-list-feeds rss_feed' => 'List all feed instances of the rss_feed importer.', + 'drush feeds-list-feeds rss_feed' => 'List all feed sources of the rss_feed importer.', + 'drush feeds-list-feeds --limit=3' => 'Only list the first three feed sources.', ), 'options' => array( - 'limit' => 'Only list [limit] feeds. Optional.', + 'limit' => 'Limit the number of feeds to show in the list. Optional.', ), ); @@ -49,8 +42,8 @@ function feeds_drush_command() { 'stdin' => 'Read the file to import from stdin. Optional.', ), 'examples' => array( - 'drush feeds-import my_importer' => 'Import the feed my_importer.', - 'drush feeds-import my_importer --nid=2' => 'Import my_importer associated with nid 2.', + 'drush feeds-import my_importer' => "Import items with the importer 'my_importer'.", + 'drush feeds-import my_importer --nid=2' => "Import item with the importer 'my_importer' for feed node 2.", ), ); @@ -61,25 +54,25 @@ function feeds_drush_command() { ), 'examples' => array( 'drush feeds-import-all' => 'Import all instances of all feeds.', - 'drush feeds-import-all my_importer' => 'Import all instances of the importer my_importer.', - 'drush feeds-import-all my_importer --limit 10' => 'Import 10 instances the feed my_importer.', + 'drush feeds-import-all my_importer' => "Import all instances of the importer 'my_importer'.", + 'drush feeds-import-all my_importer --limit 10' => "Import 10 instances the feed \'my_importer'.", ), 'options' => array( - 'limit' => 'Only import [limit] Feeds importers. Optional.', + 'limit' => 'Limit the number of feeds to import. Optional.', ), ); $items['feeds-clear'] = array( - 'description' => 'Clears a feed.', + 'description' => 'Delete all items from a feed.', 'arguments' => array( 'importer' => 'The name of the Feeds importer that will be cleared. Mandatory.', ), 'options' => array( - 'nid' => 'The nid of the Feeds importer that will be cleared. Optional.', + 'nid' => 'The ID of the Feed node that will be cleared. Required if the importer is attached to a content type.', ), 'examples' => array( - 'drush feeds-clear my_importer', - 'drush feeds-clear my_importer --nid=2', + 'drush feeds-clear my_importer' => "Deletes all items imported with the importer 'my_importer'. The importer must use the standalone import form.", + 'drush feeds-clear my_importer --nid=2' => "Deletes all items imported with the importer 'my_importer' for the feed node with ID 2. The importer must be attached to a content type.", ), ); @@ -89,7 +82,7 @@ function feeds_drush_command() { 'importers' => 'A space delimited list of Feeds importers. Mandatory.', ), 'examples' => array( - 'drush feeds-enable importer_1 importer_2', + 'drush feeds-enable importer_1 importer_2' => "Enable Feeds importers 'importer_1' and 'importer_2'.", ), ); @@ -99,7 +92,7 @@ function feeds_drush_command() { 'importers' => 'A space delimited list of Feeds importers. Mandatory.', ), 'examples' => array( - 'drush feeds-disable importer_1 importer_2', + 'drush feeds-disable importer_1 importer_2' => "Disable Feeds importers 'importer_1' and 'importer_2'.", ), ); @@ -109,7 +102,7 @@ function feeds_drush_command() { 'importers' => 'A space delimited list of Feeds importers. Mandatory.', ), 'examples' => array( - 'drush feeds-delete importer_1 importer_2', + 'drush feeds-delete importer_1 importer_2' => "Delete Feeds importers 'importer_1' and 'importer_2'.", ), ); @@ -119,7 +112,7 @@ function feeds_drush_command() { 'importers' => 'A space delimited list of Feeds importers. Mandatory.', ), 'examples' => array( - 'drush feeds-revert importer_1 importer_2', + 'drush feeds-revert importer_1 importer_2' => "Revert Feeds importers 'importer_1' and 'importer_2'.", ), ); @@ -127,6 +120,32 @@ function feeds_drush_command() { } /** + * Implements hook_drush_help(). + */ +function feeds_drush_help($section) { + switch ($section) { + case 'drush:feeds-list-importers': + return dt('Show a list of available Feeds importers with information about them.'); + case 'drush:feeds-list-feeds': + return dt("List all feed sources. You can limit the number of feed sources to display by setting the option '--limit'."); + case 'drush:feeds-import': + return dt("Import items from a feed. Follow the command with the importer name to import items with. If the importer is attached to a content type, specify also the feed node with the option '--nid'."); + case 'drush:feeds-import-all': + return dt('Import items from all feeds. Optionally specify the importer name to import all feeds for.'); + case 'drush:feeds-clear': + return dt("Delete all items from a feed. Follow the command with the importer name to delete items from. If the importer is attached to a content type, specify also the feed node with the option '--nid'."); + case 'drush:feeds-enable': + return dt('Enable the specified Feeds importers. Follow the command with a space delimited list of importer names.'); + case 'drush:feeds-disable': + return dt('Disable the specified Feeds importers. Follow the command with a space delimited list of importer names.'); + case 'drush:feeds-delete': + return dt('Delete the specified Feeds importers. Follow the command with a space delimited list of importer names.'); + case 'drush:feeds-revert': + return dt('Revert the specified Feeds importers. Follow the command with a space delimited list of importer names.'); + } +} + +/** * Prints a list of all Feeds importers. */ function drush_feeds_list_importers() { @@ -182,11 +201,11 @@ function drush_feeds_list_feeds($importer = NULL) { $rows = array(); $rows[] = array( - dt('ID'), + dt('Importer ID'), dt('Feed NID'), - dt('Imported'), - dt('Feed Source'), - dt('Process in Background'), + dt('Last imported'), + dt('Feed source'), + dt('Process in background'), ); foreach (_drush_feeds_get_all($importer, $limit) as $feed) { @@ -212,7 +231,7 @@ function drush_feeds_list_feeds($importer = NULL) { */ function drush_feeds_import($importer = NULL) { if (!strlen($importer)) { - drush_print(dt('The importer importer is required.')); + drush_set_error(dt("Please specify the importer to import items with. If the importer is attached to a content type, specify also the feed node with the option '--nid'.")); return FALSE; } @@ -224,13 +243,13 @@ function drush_feeds_import($importer = NULL) { $source = feeds_source($importer, $feed_nid)->existing(); } catch (FeedsNotExistingException $e) { - drush_print(dt('The feed @importer: @nid does not exist.', array('@importer' => $importer, '@nid' => $feed_nid))); + drush_set_error(dt('The feed @importer: @nid does not exist.', array('@importer' => $importer, '@nid' => $feed_nid))); return FALSE; } if ($filename = drush_get_option('file')) { if (!is_file($filename)) { - drush_print(dt('The file @file does not exist.', array('@file' => $filename))); + drush_set_error(dt('The file @file does not exist.', array('@file' => $filename))); return FALSE; } $result = new FeedsFileFetcherResult($filename); @@ -297,7 +316,7 @@ function _drush_feeds_create_import_batch($importer, $feed_nid) { $feed_node = FALSE; if ($feed_nid) { if (!$feed_node = node_load($feed_nid)) { - drush_print(dt('The feed node @importer: @nid does not exist.', array('@importer' => $importer, '@nid' => $feed_nid))); + drush_set_error(dt('The feed node @importer: @nid does not exist.', array('@importer' => $importer, '@nid' => $feed_nid))); return FALSE; } } @@ -325,7 +344,7 @@ function _drush_feeds_create_import_batch($importer, $feed_nid) { */ function drush_feeds_clear($importer = NULL) { if (!strlen($importer)) { - drush_print(dt('The importer importer is required.')); + drush_set_error(dt("Please specify the importer to delete all imported items from. If the importer is attached to a content type, specify also the feed node with the option '--nid'.")); return FALSE; } @@ -337,7 +356,7 @@ function drush_feeds_clear($importer = NULL) { feeds_source($importer, $feed_nid)->existing(); } catch (FeedsNotExistingException $e) { - drush_print(dt('The feed @importer: @nid does not exist.', array('@importer' => $importer, '@nid' => $feed_nid))); + drush_set_error(dt('The feed @importer: @nid does not exist.', array('@importer' => $importer, '@nid' => $feed_nid))); return FALSE; } @@ -385,7 +404,7 @@ function drush_feeds_enable() { foreach ($to_enable as $importer) { unset($disabled[$importer]); - drush_log(dt('!importer has been enabled.', array('!importer' => $importer)), 'ok'); + drush_log(dt("The importer '!importer' has been enabled.", array('!importer' => $importer)), 'ok'); } variable_set('default_feeds_importer', $disabled); @@ -423,7 +442,7 @@ function drush_feeds_disable() { $disabled = variable_get('default_feeds_importer', array()); foreach ($to_disable as $importer) { $disabled[$importer] = TRUE; - drush_log(dt('!importer has been disabled.', array('!importer' => $importer)), 'ok'); + drush_log(dt("The importer '!importer' has been disabled.", array('!importer' => $importer)), 'ok'); } variable_set('default_feeds_importer', $disabled); feeds_cache_clear(); @@ -442,7 +461,7 @@ function drush_feeds_delete() { } if ($to_delete) { - drush_print(dt('The following feeds will be deleted: !importers', array('!importers' => implode(', ', array_keys($to_delete))))); + drush_print(dt('The following importers will be deleted: !importers', array('!importers' => implode(', ', array_keys($to_delete))))); } else { return drush_print(dt('There are no importers to delete.')); @@ -454,7 +473,7 @@ function drush_feeds_delete() { foreach ($to_delete as $importer) { $importer->delete(); - drush_log(dt('!importer was deleted successfully.', array('!importer' => $importer->id)), 'ok'); + drush_log(dt("The importer '!importer' was deleted successfully.", array('!importer' => $importer->id)), 'ok'); } feeds_cache_clear(); @@ -482,11 +501,11 @@ function drush_feeds_revert() { } if ($cant_revert) { - drush_print(dt('The following feeds will be cannot be reverted: !importers', array('!importers' => implode(', ', array_keys($cant_revert))))); + drush_print(dt('The following importers cannot be reverted: !importers', array('!importers' => implode(', ', array_keys($cant_revert))))); } if ($to_revert) { - drush_print(dt('The following feeds will be reverted: !importers', array('!importers' => implode(', ', array_keys($to_revert))))); + drush_print(dt('The following importers will be reverted: !importers', array('!importers' => implode(', ', array_keys($to_revert))))); } else { return drush_print(dt('There are no importers to revert.')); @@ -498,7 +517,7 @@ function drush_feeds_revert() { foreach ($to_revert as $importer) { $importer->delete(); - drush_log(dt('!importer was reverted successfully.', array('!importer' => $importer->id)), 'ok'); + drush_log(dt("The importer '!importer' was reverted successfully.", array('!importer' => $importer->id)), 'ok'); } feeds_cache_clear();