# HG changeset patch # User Ludovic Chabant # Date 1437929659 25200 # Node ID dce482f7c62db0d6ee79bbfba5f2f0e83420f19a # Parent 32612333a367c0bdd1d7081fe59ffad827f3bfac docs: Use fenced code block syntax. diff -r 32612333a367 -r dce482f7c62d docs/api/02_components/01_commands.md --- 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