Closed (fixed)
Project:
Drush
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
17 Aug 2010 at 05:06 UTC
Updated:
31 Aug 2010 at 14:20 UTC
Jump to comment: Most recent file
This patch allows commandfiles to add options or new sections to drush commands (full command help only).
For example:
function project_issue_drush_help_alter(&$command) {
if ($command['command'] == 'sql-sync') {
$command['sections']['sanitizations'] = 'Sanitizations';
$command['sanitizations']['--no-project-issue-sanitize'] = "Don't sanitize the project issue table";
}
}
That's probably not how I'd do help alter for project issue; this just shows what is possible. Of course you can just add $command['options']['--no-project-issue-sanitize'] = ..., which would be the typical case. $command['sections'] can be defined in a commandfile as well as in help-alter, or course.
This patch also removes a small amount of code that was only useful when commands could contain spaces.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | help-alter-2.patch | 4.03 KB | greg.1.anderson |
| help-alter.patch | 3.44 KB | greg.1.anderson |
Comments
Comment #1
moshe weitzman commentedWell done.
Hmmm. I think we are ok but pls confirm that module owned commandfiles will be able to alter the help of any other command. Just wondering about custom bootstrapping in drush_core_help().
Should we move the help altering that engines do into this hook? See drush_show_help(). Further, we have a lot of options that are SVN specific for example. Might merit own section.
'sections' needs to be added to the big array in drush_get_commands(). thats our one place for documenting what the heck is possible in a command definition.
I might prefer a single array with a special 'title' element. Its a bit weird to separate out the title from the rest. I'm ok wither way.
Comment #2
moshe weitzman commentedActually, the arrays you propose does lead to clean code when displaying the help so I'm good with it.
Comment #3
greg.1.anderson commentedYep, already confirmed; that's why help bootstraps to the DRUSH_SITE level, to insure that the module-owned commandfiles are loaded. There's no way to know if we should bootstrap to this level until after we bootstrap to this level... but at least SITE is far enough, no need to go to FULL.
Sure, no problem; new patch attached.
Maybe; it would help keep options together, if some commandfile added an svn-related option. This also begs the question of whether there should be sub-sections (the options / svn section, etc.)
This hook can only alter help, whereas the engine system can do other changes to the commands. I don't think I'm in favor of splitting out help from the existing engines; the extra complexity outweights the consistency, which I think is debatable anyway -- maybe it's more consistent to have the engine help where it is.
Let me know if you feel strongly about either of those other two issues.
Comment #4
moshe weitzman commenteddon't feel strongly about those. rtbc.
in a follow-up, we should experiment with subsections like options/svn.
Comment #5
greg.1.anderson commentedI'll add some docs to drush.api.php and commit shortly.
Comment #6
greg.1.anderson commentedCommitted.