You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Drush command info (annotations/attributes) can be altered from other modules. This is done by creating and registering <em>command info alterers</em>. Alterers are classes that are able to intercept and manipulate an existing command annotation.</p>
5283
5283
<p>In the module that wants to alter a command info, add a class that:</p>
5284
5284
<ol>
5285
-
<li>The generator class namespace, relative to base namespace, should be <code>Drupal\<module-name>\Drush\CommandInfoAlterers</code> and the class file should be located under the <code>src/Drush/CommandInfoAlterers</code> directory.</li>
5285
+
<li>The class namespace, relative to base namespace, should be <code>Drupal\<module-name>\Drush\CommandInfoAlterers</code> and the class file should be located under the <code>src/Drush/CommandInfoAlterers</code> directory.</li>
5286
5286
<li>The filename must have a name like FooCommandInfoAlterer.php. The prefix <code>Foo</code> can be whatever string you want. The file must end in <code>CommandInfoAlterer.php</code>.</li>
5287
5287
<li>The class must implement the <code>\Consolidation\AnnotatedCommand\CommandInfoAltererInterface</code>.</li>
5288
5288
<li>Implement the alteration logic in the <code>alterCommandInfo()</code> method.</li>
5289
5289
<li>Along with the alter code, it's strongly recommended to log a debug message explaining what exactly was altered. This makes things easier on others who may need to debug the interaction of the alter code with other modules. Also it's a good practice to inject the the logger in the class constructor.</li>
5290
5290
</ol>
5291
5291
<p>For an example, see <ahref="https://github.com/drush-ops/drush/blob/13.x/sut/modules/unish/woot/src/Drush/CommandInfoAlterers/WootCommandInfoAlterer.php">WootCommandInfoAlterer</a> provided by the testing 'woot' module.</p>
<p>Drush lists and runs Symfony Console commands, in addition to more typical annotated commands. See <ahref="https://github.com/drush-ops/drush/blob/eed106ae4510d5a2df89f8e7fd54b41ffb0aa5fa/tests/integration/AnnotatedCommandCase.php#L178-L180">this test</a> and this <ahref="https://github.com/drush-ops/drush/blob/13.x/sut/modules/unish/woot/src/Commands/GreetCommand.php">commandfile</a>.</p>
5293
+
<p>Drush lists and runs Symfony Console commands, in addition to more typical annotated commands.
5294
+
See <ahref="https://github.com/drush-ops/drush/blob/13.x/sut/modules/unish/woot/src/Drush/Commands/GreetCommands.php">GreetCommands</a> as an example. Note that these commands must conform to the usual class name and class namespace requirements. You might need to extend the Console class if you can't rename and move it.</p>
0 commit comments