summaryrefslogtreecommitdiff
path: root/openerpcommand/__init__.py
diff options
context:
space:
mode:
authorVo Minh Thu <vmt@openerp.com>2013-01-11 14:46:57 +0100
committerVo Minh Thu <vmt@openerp.com>2013-01-11 14:46:57 +0100
commit3da57500c279cd19fa6d561eef149d708383138d (patch)
treee6ea46397217349ff0381b91346a1ba02394e14b /openerpcommand/__init__.py
parent3478333bca1a28483c1c7eb90431cb1e979c74ba (diff)
[ADD] oe: provides sane (unfucked) command-line interface.
The implementation is far from perfect. Some improvements are waiting in its previous location: lp:~openerp/openerp-command. Some docs are provided, see doc/openerp-command.rst and doc/adding-command.rst. bzr revid: vmt@openerp.com-20130111134657-im2f3uqjluyo4pm6
Diffstat (limited to 'openerpcommand/__init__.py')
-rw-r--r--openerpcommand/__init__.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/openerpcommand/__init__.py b/openerpcommand/__init__.py
new file mode 100644
index 00000000000..53d456c7639
--- /dev/null
+++ b/openerpcommand/__init__.py
@@ -0,0 +1,61 @@
+import argparse
+import textwrap
+
+from .call import Call
+from .client import Open, Show, ConsumeNothing, ConsumeMemory, LeakMemory, ConsumeCPU
+from .benchmarks import Bench, BenchRead, BenchFieldsViewGet, BenchDummy, BenchLogin
+from .bench_sale_mrp import BenchSaleMrp
+from . import common
+
+from . import conf # Not really server-side (in the `for` below).
+from . import drop
+from . import initialize
+from . import model
+from . import module
+from . import read
+from . import run_tests
+from . import scaffold
+from . import uninstall
+from . import update
+
+command_list_server = (conf, drop, initialize, model, module, read, run_tests,
+ scaffold, uninstall, update, )
+
+command_list_client = (Call, Open, Show, ConsumeNothing, ConsumeMemory,
+ LeakMemory, ConsumeCPU, Bench, BenchRead,
+ BenchFieldsViewGet, BenchDummy, BenchLogin,
+ BenchSaleMrp, )
+
+def main_parser():
+ parser = argparse.ArgumentParser(
+ usage=argparse.SUPPRESS,
+ description=textwrap.fill(textwrap.dedent("""\
+ OpenERP Command provides a set of command-line tools around
+ the OpenERP framework: openobject-server. All the tools are
+ sub-commands of a single oe executable.""")),
+ epilog="""Use <command> --help to get information about the command.""",
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ )
+ description = []
+ for x in command_list_server:
+ description.append(x.__name__[len(__package__)+1:])
+ if x.__doc__:
+ description.extend([
+ ":\n",
+ textwrap.fill(str(x.__doc__).strip(),
+ subsequent_indent=' ',
+ initial_indent=' '),
+ ])
+ description.append("\n\n")
+ subparsers = parser.add_subparsers(
+ title="Available commands",
+ help=argparse.SUPPRESS,
+ description="".join(description[:-1]),
+ )
+ # Server-side commands.
+ for x in command_list_server:
+ x.add_parser(subparsers)
+ # Client-side commands. TODO one per .py file.
+ for x in command_list_client:
+ x(subparsers)
+ return parser