Extending / Intermediate / Nut Console Commands
Note: You are currently reading the documentation for Bolt 3.7. Looking for the documentation for Bolt 5.2 instead?
With your extension, you may want to provide console commands via Bolt's built-
in nut
command.
Bolt provides the registerNutCommands()
that accepts an array of
Symfony\Component\Console\Command\Command
objects for registration as
Nut commands.
A simple example of an extension that registers some Nut commands would look like:
NOTE: There are two classes you might choose to extend for a Nut application.
For simple Nut commands that don't need to interact with any services provided
by Bolt itself, you need only extend Symfony\Component\Console\Command\Command
More complex commands that need to access Bolt provided services should
alternatively extend Bolt\Nut\BaseCommand
.
Creating a Command Class¶
The command class should have both a minimum of configure()
and execute()
functions.
In the above example we've added an option --summary
and an (optional)
argument labelled type
.
This can then be called from your Bolt installation:
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.