You are here

function module_builder_callback_build in Module Builder 6.2

Same name and namespace in other branches
  1. 7 drush/module_builder.drush.inc \module_builder_callback_build()

Module builder drush command callback.

Form: $drush mb machine_name hookA hookB hookC where 'hookA' is the short name, ie 'menu' not hook_menu'.

1 string reference to 'module_builder_callback_build'
module_builder_drush_command in drush/module_builder.drush.inc
Implementation of hook_drush_command().

File

drush/module_builder.drush.inc, line 160
Module builder drush commands.

Code

function module_builder_callback_build() {
  $commands = func_get_args();

  // Build the module data.
  $module_data = module_builder_build_data($commands);

  // What to build
  $build = drush_get_option('build');

  // write options:
  // - all -- everything we can do
  // - code -- code files, not info (module + install _ ..?)
  // - info -- only info fole
  // - module -- only module file
  // - install -- only install file
  // - ??? whatever hooks need
  // No build: set nice default.
  if (!$build) {

    // If we are adding, 'code' is implied
    if (drush_get_option('add')) {
      $build = 'code';
    }
    elseif (drush_get_option(array(
      'write',
      'go',
    ))) {
      $build = 'all';
    }
    else {
      $build = 'code';
    }
  }

  //print_r($build);

  // Make a list
  $build_list = explode(' ', $build);

  // Multi build: set a single string to switch on below.
  if (count($build_list) > 1) {
    $build = 'code';
  }

  //print_r($build_list);

  // Build files.
  // Include generating component file.
  module_builder_include('generate');

  // Build module code in all cases bar 'info'.
  if ($build != 'info') {

    // Check hook data file exists.
    if (!_module_builder_check_hook_data()) {
      return drush_set_error("DRUSH_NOT_COMPLETED', 'No hook definitions found. You need to download hook definitions before using this module: see the command 'mbdl'.");
    }
    module_builder_build_module($commands, $module_data, $build_list);
  }

  // Build info code in cases 'info' and 'all'.
  if ($build == 'info' or $build == 'all') {
    module_builder_build_info($commands, $module_data);
  }

  /*
  switch ($build) {
    case 'info':
      // info and stop
      module_builder_callback_info($commands, $module_data);
      break;
    case 'all':
      // info and fall through
      module_builder_callback_info($commands, $module_data);
    case 'code':
      // this is just here to look pretty
    default:
      // anything else, eg module, install etc
      module_builder_callback_module($commands, $module_data, $build_list);
  }
  */
  if (drush_get_option('go')) {
    pm_module_manage(array(
      array_shift($commands),
    ), TRUE);
  }
}