drush mb-buildfor drush 7x
Generate the code for a new Drupal module, including file headers and hook implementations.
drush mb-build
mb-build is a Drush command from the module_builder project.
module_builder-
Aliases
mb-build has 1 alias/es:
drush mb
-
Arguments
mb-build accepts 11 argument/s:
module name : The machine name of the module. Use '.' to specify the current folder name.
hooks : Short names of hooks, separated by spaces.
presets: : Names of preset groups of hooks, e.g., 'block'. Use the 'presets:' marker to separate this from prior commands, eg 'mymodule hook_a hook_b presets: block'.
plugins: : Names of plugin types, using the suffix of the plugin manager service ID, e.g., 'block'. Use the 'plugins:' marker to separate this from prior commands, eg 'mymodule hook_a hook_b plugins: block'.
routes: : Menu paths, separated by spaces. Use the 'routes:' marker to separate this from prior commands, eg 'mymodule hook_a hook_b routes: module/path module/otherpath'.
perms: : Permission names, separated by spaces. Use the 'perms:' marker to separate this from prior commands, eg 'mymodule hook_a hook_b perms: 'administer my module''. Quote strings that contain spaces.
services: : IDs of services, separated by spaces.
settings_form! : Add this argument to add a settings form to the module.
api! : Add this argument to add an api.php file to the module.
readme! : Add this argument to add a README file to the module.
tests! : Add this argument to add a Simpletest test case file to the module.
-
Options
mb-build accepts 12 option/s:
--noi : Disables interactive mode.
--data : Location to read hook data. May be absolute, or relative to Drupal files dir. Defaults to 'files/hooks'.
--build : Which module components to generate: - 'info' makes the info file. - 'readme' makes README file. - 'api' makes an api.php file to document hooks. It will parse existing module files for calls to module_invoke_all() and use those as starter file content. - 'tests' makes the tests folder and test case file. - 'module', 'install' make the foo.module or foo.install file respectively. - 'FILE': If custom modules define other files to output, you can request those too, omitting the module root name part and any .inc extension, eg 'views' for 'foo.views.inc. - 'code' generates code files as needed: the module and install files, and any files requested by hooks. - 'all' generates everything, including any code files needed by the requested hooks. Default is 'all' if writing new files, 'code' if appending to file or outputting only to terminal.
--write : Write files to sites/all/modules. Will prompt to overwrite existing files; use yes to force. Use quiet to suppress output to the terminal.
--go : Write all module files and enable the new module. Take two commands into the shower? Not me.
--add : Append hooks to module file. Implies 'write build=code'. Warning: will not check hooks already exist.
--name : Readable name of the module.
--desc : Description (for the admin module list).
--helptext : Module help text (for the system help).
--dep : Dependencies, separated by spaces, eg "forum views".
--package : Module package.
--parent : Name of a module folder to place this new module into; use if this module is to be added to an existing package. Use '.' for the current working directory.
-
Examples
Generate module code with hook_menu, hook_cron, hook_nodeapi.
drush mb my_module menu cron nodeapi
Generate module info with readable name and dependencies.
drush mb my_module --build=info --name="My module" --dep="forum views"
Generate both module files, write files and also output to terminal.
drush mb my_module menu cron --write --name="My module" --dep="forum views"
Generate module code, write files and also output to terminal.
drush mb my_module menu cron --write
Generate both module files, write files and output nothing to terminal.
drush mb my_module menu cron --write --quiet --name="My module" --dep="forum views"
Generate code for hook_cron and add it to the existing my_module.module file.
drush mb my_module menu cron --add
Generate both module files, write files to a folder my_module inside the cck folder.
drush mb my_module menu cron --write --parent=cck
Generate both module files, write files to a folder my_module in the current working directory.
drush mb my_module menu cron --write --parent=.
-
Comments
comments powered by Disqus