[IMP] hw_proxy: initial commit for the posbox's documentation
[odoo/odoo.git] / openerpcommand / __init__.py
1 import argparse
2 import textwrap
3
4 from .call import Call
5 from .client import Open, Show, ConsumeNothing, ConsumeMemory, LeakMemory, ConsumeCPU
6 from .benchmarks import Bench, BenchRead, BenchFieldsViewGet, BenchDummy, BenchLogin
7 from .bench_sale_mrp import BenchSaleMrp
8 from . import common
9
10 from . import conf # Not really server-side (in the `for` below).
11 from . import cron
12 from . import drop
13 from . import initialize
14 from . import model
15 from . import module
16 from . import read
17 from . import scaffold
18 from . import uninstall
19 from . import update
20 from . import web
21 from . import grunt_tests
22
23 command_list_server = (conf, cron, drop, initialize, model, module, read,
24                        scaffold, uninstall, update, web, grunt_tests, )
25
26 command_list_client = (Call, Open, Show, ConsumeNothing, ConsumeMemory,
27                        LeakMemory, ConsumeCPU, Bench, BenchRead,
28                        BenchFieldsViewGet, BenchDummy, BenchLogin,
29                        BenchSaleMrp, )
30
31 def main_parser():
32     parser = argparse.ArgumentParser(
33         usage=argparse.SUPPRESS,
34         description=textwrap.fill(textwrap.dedent("""\
35                     OpenERP Command provides a set of command-line tools around
36                     the OpenERP framework: openobject-server. All the tools are
37                     sub-commands of a single oe executable.""")),
38         epilog="""Use <command> --help to get information about the command.""",
39         formatter_class=argparse.RawDescriptionHelpFormatter,
40     )
41     description = []
42     for x in command_list_server:
43         description.append(x.__name__[len(__package__)+1:])
44         if x.__doc__:
45             description.extend([
46                 ":\n",
47                 textwrap.fill(str(x.__doc__).strip(),
48                               subsequent_indent='  ',
49                               initial_indent='  '),
50             ])
51         description.append("\n\n")
52     subparsers = parser.add_subparsers(
53         title="Available commands",
54         help=argparse.SUPPRESS,
55         description="".join(description[:-1]),
56     )
57     # Server-side commands.
58     for x in command_list_server:
59         x.add_parser(subparsers)
60     # Client-side commands. TODO one per .py file.
61     for x in command_list_client:
62         x(subparsers)
63     return parser