aboutsummaryrefslogblamecommitdiffstats
path: root/README.dev
blob: 4cbf554b3ea7146dbe69bd99a854702b4a38829c (plain) (tree)



























                                                                         





                                    
Extending BE
============

To write a plugin, you simply create a new file in the becommands
directory.  Take a look at one of the simpler plugins (e.g. open.py)
for an example of how that looks, and to start getting a feel for the
libbe interface.

To fit into the current framework, your extension module should
provide the following elements:
  __desc__
    A short string describing the purpose of your plugin
  execute(args)
    The entry function for your plugin.  args is everything from
    sys.argv after the name of your plugin (e.g. for the command
    `be open abc', args=['abc']).
  help()
     Return the string to be output by `be help <yourplugin>',
     `be <yourplugin> --help', etc.

While that's all that's strictly necessary, many plugins (all the
current ones) use libbe.cmdutil.CmdOptionParser to provide a
consistent interface
  get_parser()
    Return an instance of CmdOptionParser("<usage string>").  You can
    alter the parser (e.g. add some more options) before returning it.

Again, you can just browse around in becommands to get a feel for things.

Run any doctests in your plugin with
  be$ python test.py <yourplugin>
for example
  be$ python test.py merge