This is something that has been annoying me for considerable time, so I'm finally opening an issue for it.

Consider this input (I've skipped to the part with the questions that ignore my answers):

$ drush mb --write
[snip]
Do you want a Admin settings form (y/n) (optional) [n]: y
Enter the Permissions, as a space separated list (optional): "administer my module"
  [1] node: Define your own content type (node)
  [2] nodeapi: Interact with nodes
  [3] block: Add blocks to your module
  [4] field-type: Define a field type
  [5] field-widget: Define a field widget
  [6] field-formatter: Define a field formatter
  [7] views: Define views data
Enter the Hook preset groups, as a space separated list (optional):
Enter the Hook implementations, as a space separated list (optional): cron
Enter the Router paths, as a space separated list (optional):
Do you want a api.php file (y/n) (optional) [n]: n
Do you want a README file (y/n) [y]: y
Do you want a Simpletest test case class (y/n) (optional) [n]: n

Of these, any of the y/n questions always assume y, even if the default says [n].

An api.php file is always created, a Simpletest test case class is always created, and an admin settings form is always generated.

Comments

wizonesolutions created an issue. See original summary.

joachim’s picture

Status: Active » Fixed

Turned out that this was because the Drush command was passing 'n' in to the code builder library, which expects an actual boolean -- and casting turns any string into TRUE.

Fixed and pushed to my fork at https://github.com/joachim-n/drush/tree/module-builder-commands.

Thanks for reporting!

wizonesolutions’s picture

Cool! How do I use your fork?

joachim’s picture

You can use it instead of Drush. Alternatively -- and since I don't manage to keep up with changes in Drush, and the merge request isn't getting any traction -- check it out somewhere else, and symlink the module_builder command folder into your Drush's command folder.

wizonesolutions’s picture

So I cloned your Drush, ran composer install, and linked the module_builder folder into ~/.drush. However, I get this when trying to use it:

Fatal error: Class 'DrupalCodeBuilder\Factory' not found in /home/vagrant/module-builder-commands/commands/module_builder/module_builder.drush.inc on line 28

Call Stack:
    0.0001     224328   1. {main}() /usr/local/share/drush/drush:0
    0.0177     759192   2. require('phar:///usr/local/share/drush/drush/drush') /usr/local/share/drush/drush:10
    0.0180     808464   3. drush_startup() phar:///usr/local/share/drush/drush/drush:114
    0.0190     976544   4. drush_main() phar:///usr/local/share/drush/drush/includes/startup.inc:325
    0.2269    9736768   5. Drush\Boot\BaseBoot->bootstrap_and_dispatch() phar:///usr/local/share/drush/drush/includes/preflight.inc:66
    2.2424   90280472   6. drush_dispatch() phar:///usr/local/share/drush/drush/lib/Drush/Boot/BaseBoot.php:67
    2.3705   94080584   7. call_user_func_array:{phar:///usr/local/share/drush/drush/includes/command.inc:185}() phar:///usr/local/share/drush/drush/includes/command.inc:185
    2.3705   94080936   8. drush_command() phar:///usr/local/share/drush/drush/includes/command.inc:185
    2.3707   94085424   9. call_user_func_array:{phar:///usr/local/share/drush/drush/includes/command.inc:212}() phar:///usr/local/share/drush/drush/includes/command.inc:212
    2.3707   94085624  10. module_builder_drush_init() phar:///usr/local/share/drush/drush/includes/command.inc:212
    2.3707   94089336  11. module_builder_drush_init_helper() /home/vagrant/module-builder-commands/commands/module_builder/module_builder.drush.inc:17

Drush command terminated abnormally due to an unrecoverable error.                                                                                                   [error]
Error: Class 'DrupalCodeBuilder\Factory' not found in /home/vagrant/module-builder-commands/commands/module_builder/module_builder.drush.inc, line 28

Drush 8.1.0. I'll try copying the folder and putting drupal_code_builder in libraries instead.

joachim’s picture

Ah oops.

Do 'composer require drupal-code-builder/drupal-code-builder' in your real Drush.

wizonesolutions’s picture

Nah, that didn't work either. Dunno why symlinking didn't work. Maybe because the actual Drush I'm running is still the main one and it doesn't autoload or something and then MB doesn't know where to look for autoload.php.

wizonesolutions’s picture

Oh, I missed #6. I already just cleaned up regular Module Builder's output, but I will try this next time!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.