diff options
| author | Antony Lesuisse <lesuisse@gmail.com> | 2014-05-29 18:33:04 +0200 |
|---|---|---|
| committer | Antony Lesuisse <lesuisse@gmail.com> | 2014-05-29 18:33:04 +0200 |
| commit | d4624fa826a5e9542782f2c53c8ba2c766d093bc (patch) | |
| tree | be214779eb6d1f17157aa48e72fbcbf95405e38b /doc/adding-command.rst | |
| parent | 045ecc603e67911a5390c812cb6b5b123d9c190e (diff) | |
[IMP] repository cleanup
- move packaging stuff to setup
- remove historical stuff
- remove oe, odoo-cmd-fme will be merged with the convered commands
- add an odoo.py script to run odo and boostrap it
- simplify README
- prepare to move documentation to the github wiki
Diffstat (limited to 'doc/adding-command.rst')
| -rw-r--r-- | doc/adding-command.rst | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/doc/adding-command.rst b/doc/adding-command.rst deleted file mode 100644 index 5a177b06817..00000000000 --- a/doc/adding-command.rst +++ /dev/null @@ -1,34 +0,0 @@ -.. _adding-command: - -Adding a new command -==================== - -``oe`` uses the argparse_ library to implement commands. Each -command lives in its own ``openerpcommand/<command>.py`` file. - -.. _argparse: http://docs.python.org/2.7/library/argparse.html - -To create a new command, probably the most simple way to get started is to -copy/paste an existing command, say ``openerpcommand/initialize.py`` to -``openerpcommand/foo.py``. In the newly created file, the important bits -are the ``run(args)`` and ``add_parser(subparsers)`` functions. - -``add_parser``'s responsability is to create a (sub-)parser for the command, -i.e. describe the different options and flags. The last thing it does is to set -``run`` as the function to call when the command is invoked. - -.. code-block:: python - - > def add_parser(subparsers): - > parser = subparsers.add_parser('<command-name>', - > description='...') - > parser.add_argument(...) - > ... - > parser.set_defaults(run=run) - -``run(args)`` actually implements the command. It should be kept as simple as -possible and delegate most of its work to small functions (probably placed at -the top of the new file). In other words, its responsability is mainly to -deal with the presence/absence/pre-processing of ``argparse``'s arguments. - -Finally, the module must be added to ``openerpcommand/__init__.py``. |
