/[drupal]/contributions/modules/module_builder/drush/module_builder.drush.inc
ViewVC logotype

Diff of /contributions/modules/module_builder/drush/module_builder.drush.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.49, Sat Oct 24 21:11:03 2009 UTC revision 1.1.2.50, Sat Oct 24 22:55:55 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: module_builder.drush.inc,v 1.1.2.48 2009/10/24 19:19:55 joachim Exp $  // $Id: module_builder.drush.inc,v 1.1.2.49 2009/10/24 21:11:03 joachim Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 146  function module_builder_callback_build() Line 146  function module_builder_callback_build()
146    
147    $commands = func_get_args();    $commands = func_get_args();
148    
149      // Build the module data.
150      $module_data = module_builder_build_data($commands);
151    
152    // What to build    // What to build
153    $build = drush_get_option('build');    $build = drush_get_option('build');
154    
# Line 184  function module_builder_callback_build() Line 187  function module_builder_callback_build()
187    }    }
188    
189    //print_r($build_list);    //print_r($build_list);
190    
191      // Build files.
192      // Build module code in all cases bar 'info'.
193      if ($build != 'info') {
194        module_builder_callback_module($commands, $module_data, $build_list);
195      }
196      // Build info code in cases 'info' and 'all'.
197      if ($build == 'info' or $build == 'all') {
198        module_builder_callback_info($commands, $module_data);
199      }
200    
201      /*
202    switch ($build) {    switch ($build) {
203      case 'info':      case 'info':
204        // info and stop        // info and stop
205        module_builder_callback_info($commands);        module_builder_callback_info($commands, $module_data);
206        break;        break;
207      case 'all':      case 'all':
208        // info and fall through        // info and fall through
209        module_builder_callback_info($commands);        module_builder_callback_info($commands, $module_data);
210      case 'code':      case 'code':
211        // this is just here to look pretty        // this is just here to look pretty
212      default:      default:
213        // anything else, eg module, install etc        // anything else, eg module, install etc
214        module_builder_callback_module($commands, $build_list);        module_builder_callback_module($commands, $module_data, $build_list);
215    }    }
216      */
217    
218    if (drush_get_option('go')) {    if (drush_get_option('go')) {
219      pm_module_manage(array(array_shift($commands)), TRUE);      pm_module_manage(array(array_shift($commands)), TRUE);
# Line 206  function module_builder_callback_build() Line 221  function module_builder_callback_build()
221  }  }
222    
223  /**  /**
224     * Helper function to build the array of module_data.
225     */
226    function module_builder_build_data($commands) {
227      // The first argument is the module machine name.
228      $module_data['module_root_name'] = array_shift($commands);
229    
230      // Heap of defaults. Later find some nice way of asking for these.
231      //$data['module_readable_name'] = ucfirst($data['module_root_name']);
232      //$data['module_short_description'] = 'Description';
233      // todo: some function in common.inc to set defaults?
234    
235      $module_data['module_readable_name']     = drush_get_option('name');
236      $module_data['module_short_description'] = drush_get_option('desc');
237      $module_data['module_help_text']         = drush_get_option('help');
238      $module_data['module_dependencies']      = drush_get_option('dep');
239      $module_data['module_package']           = drush_get_option('package');
240    
241      return $module_data;
242    }
243    
244    /**
245   * Handles the callback for module code generation.   * Handles the callback for module code generation.
246   *   *
247     * @param $commands
248     *    The drush array of commands.
249     * @param $module_data
250     *    An array of module data. Passed by reference so file information can
251     *    be added by module_builder_generate_module().
252   * @param $build_list   * @param $build_list
253   *    An array of requested code files to output   *    An array of requested code files to output
254   *    'code' or 'all' means all of them.   *    'code' or 'all' means all of them.
255   */   */
256  function module_builder_callback_module($commands, $build_list) {  function module_builder_callback_module($commands, &$module_data, $build_list) {
257    // The first argument is the module machine name.    // The first argument is the module machine name.
258    $data['module_root_name'] = array_shift($commands);    array_shift($commands);
259    
260    foreach ($commands as $hook_name) {    foreach ($commands as $hook_name) {
261      $data['hooks']["hook_$hook_name"] = TRUE;      $module_data['hooks']["hook_$hook_name"] = TRUE;
262    }    }
263    
264    //drush_print_r($data);    //drush_print_r($module_data);
265      //exit;
266    /*    /*
267    $input = drush_input('input?...');    $input = drush_input('input?...');
268    drush_print("You entered: >$input<");    drush_print("You entered: >$input<");
269    */    */
270    
   // Heap of defaults. Later find some nice way of asking for these.  
   $data['module_readable_name'] = ucfirst($data['module_root_name']);  
   $data['module_short_description'] = 'Description';  
   
271    // Generate all our code.    // Generate all our code.
272    $module_code = module_builder_generate_module($data, drush_get_option('add'));    $module_code = module_builder_generate_module($module_data, drush_get_option('add'));
273    
274    if (is_null($module_code)) {    if (is_null($module_code)) {
275      return drush_set_error('DRUSH_NOT_COMPLETED', 'No module code has been generated: perhaps you have specified invalid hook names or hooks this module does not know about.');      return drush_set_error('DRUSH_NOT_COMPLETED', 'No module code has been generated: perhaps you have specified invalid hook names or hooks this module does not know about.');
# Line 242  function module_builder_callback_module( Line 280  function module_builder_callback_module(
280      // We have keys in module_code that are entire filenames, eg 'foo.install'      // We have keys in module_code that are entire filenames, eg 'foo.install'
281      // We have array items in build_list that are sort of file endings, eg 'install'      // We have array items in build_list that are sort of file endings, eg 'install'
282      // Match them up!      // Match them up!
283      $requested_files = module_builder_requested_filenames($data['module_root_name'], array_keys($module_code), $build_list);      $requested_files = module_builder_requested_filenames($module_data['module_root_name'], array_keys($module_code), $build_list);
284    }    }
285    else {    else {
286      // Meh we want the lot.      // Meh we want the lot.
# Line 295  function module_builder_requested_filena Line 333  function module_builder_requested_filena
333  /**  /**
334   * Handles the callback for info code generation.   * Handles the callback for info code generation.
335   */   */
336  function module_builder_callback_info($commands) {  function module_builder_callback_info($commands, $module_data) {
   // The first argument is the module machine name.  
   $data['module_root_name'] = array_shift($commands);  
   
   $data['module_readable_name']     = drush_get_option('name');  
   $data['module_short_description'] = drush_get_option('desc');  
   $data['module_help_text']         = drush_get_option('help');  
   $data['module_dependencies']      = drush_get_option('dep');  
   $data['module_package']           = drush_get_option('package');  
   
337    module_builder_include('generate_info');    module_builder_include('generate_info');
338    $info_code = module_builder_generate_info($data);    $info_code = module_builder_generate_info($module_data);
339    
340    module_builder_drush_output_code($data['module_root_name'], $data['module_root_name'] . '.info', $info_code);    module_builder_drush_output_code($module_data['module_root_name'], $module_data['module_root_name'] . '.info', $info_code);
341  }  }
342    
343  /**  /**

Legend:
Removed from v.1.1.2.49  
changed lines
  Added in v.1.1.2.50

  ViewVC Help
Powered by ViewVC 1.1.2