Drush Command
dereine - May 16, 2009 - 14:59
| Project: | Module Builder |
| Version: | HEAD |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
How awesome would it be, if there is a drush command to create modules
Just brainstorming

#1
I 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 :)
#2
i didn't jumped in the code of the module, but is there something like a central builder function?
#3
Yup, 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).
#4
I'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.
#5
I'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?
#6
drush.php mb(short for module builder) hook0... hookn
like drush.php dl module1 module2
#7
You'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?
#8
ok alternative suggestion
$drush mb mymodule --description description --dependencies module1 module2 --core 6.x --hooks hook1 hook2$drush mb mymodule --description description --dependencies module1 module2 --core 6.x hook1 hooknSure don't use hook_foo, use foo.
Wow this will be very awesome.
#9
Committed 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.
#10
awesome!
#11
Done.
Try the latest version when the dev release is up.
'drush help mb' will explain everything I hope.
Any problems file new issues :)
#12
Automatically closed -- issue fixed for 2 weeks with no activity.