Closed (fixed)
Project:
Module Builder
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
16 May 2009 at 14:59 UTC
Updated:
2 Sep 2013 at 04:27 UTC
How awesome would it be, if there is a drush command to create modules
Just brainstorming
Comments
Comment #1
joachim commentedI don't use drush -- tried it, couldn't get it to work on OS X with MAMP.
But definitely would be a cool feature -- feel free to submit a patch :)
Comment #2
dawehneri didn't jumped in the code of the module, but is there something like a central builder function?
Comment #3
joachim commentedYup, there's this:
function generate_module($form_values) {
but as you can tell it's dependent on the form values.
So a first step would be to abstract that out, with something like:
generate_module($module_name, $module_info, $requested_hooks)
where $module_info is an array of various properties, and $requested_hooks is of the form ('requested_hook_name' => TRUE).
Comment #4
joachim commentedI've committed a change to generate_module and generate_info: these now take a general array of options (which are mostly identical to the form values).
See function header for documentation.
This opens the way to other modules calling these functions to get generated module code.
Comment #5
joachim commentedI'm having a play with drush and I've made a basic drush command.
So now I find the first implementation hurdle: how is the user going to specify the desired hooks?
Asking (y/n) for each one will take forever, and having to type them in will be tedious, surely?
Did you have anything in mind?
Comment #6
dawehnerdrush.php mb(short for module builder) hook0... hookn
like drush.php dl module1 module2
Comment #7
joachim commentedYou're missing the input of the module machine name, which is essential.
So:
$ drush mb mymodule hook0 [...] hookn
I would use the short name of each hook, eg 'block' rather than 'hook_block' to save on typing.
What about things like human name, description, and dependencies -- would you leave those to be added by hand to the info file once it's been written?
Comment #8
dawehnerok alternative suggestion
Sure don't use hook_foo, use foo.
Wow this will be very awesome.
Comment #9
joachim commentedCommitted drush support.
It outputs code to the terminal for now, so you have to deal with it yourself.
If someone points me at the right way to write files in command line PHP / drush, I'll look at having it write the module files directly.
Comment #10
dawehnerawesome!
Comment #11
joachim commentedDone.
Try the latest version when the dev release is up.
'drush help mb' will explain everything I hope.
Any problems file new issues :)
Comment #13
Gastonia commenteddid this ever go anywhere? Just tried a drush help mb but got an invalid command (Drush 6)
Comment #14
Gastonia commentedAh, I see the plugin now, thx.
For others that come across the thread:
https://drupal.org/project/module_builder