'node_export_import_drush_callback', 'description' => "Import node code from a previous export.", ); return $items; } /** * Implementation of hook_drush_help(). * * This function is called whenever a drush user calls * 'drush help ' * * @param * A string with the help section (prepend with 'drush:') * * @return * A string with the help text for your command. */ function node_export_drush_help($section) { switch ($section) { case 'drush: node_import': return dt("TODO write me"); } } /** * Drush command callback. * * Import nodes from data. */ function node_export_import_drush_callback() { $commands = func_get_args(); $node_code = file_get_contents("php://stdin", "r"); $import = node_export_node_decode($node_code); // I get an object here. is that right? $types_exist = node_export_import_types_check($import); if ($types_exist) { foreach ($import as $new_node) { // this doesn't work because of object / array issues $new_nid = node_export_node_save($new_node); drush_print(dt("Imported node $new_nid: '" . $new_node->title . "'.")); } } else { return drush_set_error('DRUSH_NOT_COMPLETED', 'Problem found with the import file. Check the node types exist.'); } }