Mercurial > piecrust2
changeset 513:dce482f7c62d
docs: Use fenced code block syntax.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 26 Jul 2015 09:54:19 -0700 |
parents | 32612333a367 |
children | c9c305645e5f |
files | docs/api/02_components/01_commands.md |
diffstat | 1 files changed, 4 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/api/02_components/01_commands.md Sun Jul 26 09:53:59 2015 -0700 +++ b/docs/api/02_components/01_commands.md Sun Jul 26 09:54:19 2015 -0700 @@ -1,28 +1,26 @@ --- title: Chef Commands -needs_pygments: true --- To provide new `chef` commands, you need to override the `getCommands` method of your plugin, and return command instances: -{% highlight 'python' %} +```python class MyPlugin(PieCrustPlugin): name = 'myplugin' def getCommands(self): return [ MyNewCommand()] -{% endhighlight %} +``` To create a command class, inherit from the `ChefCommand` base class: -{% highlight 'python' %} +```python from piecrust.commands.base import ChefCommand - class MyNewCommand(ChefCommand): def __init__(self): super(MyNewCommand, self).__init__() @@ -34,7 +32,7 @@ def run(self, ctx): print("Doing %s" % ctx.args.thing) -{% endhighlight %} +``` * The `name` will be used for command line invocation, _i.e._ your new command