diff --git a/hacked.drush.inc b/hacked.drush.inc index 3687643..c665a71 100644 --- a/hacked.drush.inc +++ b/hacked.drush.inc @@ -19,7 +19,6 @@ function hacked_drush_help($section) { return dt('Show details of the files in one project, and the hacked/unhacked status of those files.'); case 'drush:hacked-diff': return dt('Output a unified diff of the specified project.'); - } } @@ -36,38 +35,34 @@ function hacked_drush_command() { $items['hacked-list-projects'] = array( 'description' => "List all projects that can be analysed by Hacked! ", - 'drupal dependencies' => array('hacked'), 'options' => array( - '--force-rebuild' => 'Rebuild the Hacked! report instead of getting a cached version.' + 'force-rebuild' => 'Rebuild the Hacked! report instead of getting a cached version.' ), 'aliases' => array('hlp'), ); $items['hacked-lock-modified'] = array( 'description' => "Lock all projects that Hacked! detects are modified, so that drush pm-updatecode will not touch them. (drush-4.x+ only)", - 'drupal dependencies' => array('hacked'), ); $items['hacked-details'] = array( 'description' => "Show the Hacked! report about a specific project.", - 'drupal dependencies' => array('hacked'), 'arguments' => array( 'project' => 'The machine name of the project to report on.', ), 'options' => array( - '--include-unchanged' => 'Show the files that are unchanged too.', + 'include-unchanged' => 'Show the files that are unchanged too.', ), 'aliases' => array('hd'), ); $items['hacked-diff'] = array( 'description' => "Output a unified diff of the project specified.", - 'drupal dependencies' => array('hacked'), 'arguments' => array( 'project' => 'The machine name of the project to report on.', ), 'options' => array( - '--diff-options' => 'Command line options to pass through to the diff command.' + 'diff-options' => 'Command line options to pass through to the diff command.' ), ); @@ -81,6 +76,7 @@ function hacked_drush_command() { * So you'll want to be very careful if you call this! */ function hacked_calculate_project_data_drush($projects, $force = FALSE, $redirect = NULL) { + hacked_load_dependencies(); include_once './includes/batch.inc'; // Try to get the report form cache if we can. @@ -98,10 +94,11 @@ function hacked_calculate_project_data_drush($projects, $force = FALSE, $redirec ); } + $command = drush_get_command(); $batch = array( 'operations' => $operations, 'finished' => 'hacked_build_report_batch_finished_drush', - 'file' => drupal_get_path('module', 'hacked') . '/hacked.report.inc', + 'file' => $command['path'] . '/hacked.report.inc', 'title' => t('Building report'), ); @@ -135,6 +132,7 @@ function hacked_build_report_batch_finished_drush($success, $results, $operation * Drush command callback that shows the listing of changed/unchanged projects. */ function drush_hacked_list_projects() { + hacked_load_dependencies(); // Go get the data: module_load_include('inc', 'update', 'update.report'); @@ -322,13 +320,10 @@ function drush_hacked_details($short_name) { } $row[] = $file; - - $rows[] = $row; } - drush_print_table($rows, TRUE); - + drush_print_table($rows, TRUE); } /** @@ -377,7 +372,17 @@ function drush_hacked_diff($short_name) { } drush_print($line); - } +} +/** + * Allow Hacked! to be used without being enabled, like a drush command + * installed on a platform. + */ +function hacked_load_dependencies() { + if (!module_exists('hacked')) { + include_once 'hacked.module'; + include_once 'includes/hacked_project.inc'; + include_once 'hacked.report.inc'; + } } diff --git a/hacked.report.inc b/hacked.report.inc index 20659a8..70eb089 100644 --- a/hacked.report.inc +++ b/hacked.report.inc @@ -35,10 +35,12 @@ function hacked_reports_rebuild() { * Batch callback to build the hacked report. */ function hacked_build_report_batch($project_name, &$context) { + hacked_load_dependencies(); + if (!isset($context['results']['report'])) { $context['results']['report'] = array(); } - module_load_include('inc', 'hacked', 'includes/hacked_project'); + $project = new hackedProject($project_name); $context['results']['report'][$project_name] = $project->compute_report(); $context['message'] = t('Finished processing: @name', array('@name' => $project->title()));