Drush Command

dereine - May 16, 2009 - 14:59
Project:Module Builder
Version:HEAD
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

How awesome would it be, if there is a drush command to create modules

Just brainstorming

#1

joachim - May 17, 2009 - 17:03

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

dereine - May 17, 2009 - 20:02

i didn't jumped in the code of the module, but is there something like a central builder function?

#3

joachim - May 17, 2009 - 21:07

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

joachim - May 22, 2009 - 18:25

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

joachim - June 20, 2009 - 15:53

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

dereine - June 21, 2009 - 14:01

drush.php mb(short for module builder) hook0... hookn

like drush.php dl module1 module2

#7

joachim - June 21, 2009 - 22:51

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

dereine - June 21, 2009 - 22:56

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 hookn

Sure don't use hook_foo, use foo.

Wow this will be very awesome.

#9

joachim - July 20, 2009 - 21:32

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

dereine - July 20, 2009 - 22:55

awesome!

#11

joachim - July 22, 2009 - 20:27
Status:active» fixed

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

System Message - August 5, 2009 - 20:30
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.