Merge lp:~openerp-dev/openerp-command/trunk-better_help-cto into lp:openerp-command

Proposed by Samus CTO (OpenERP)
Status: Merged
Merged at revision: 182
Proposed branch: lp:~openerp-dev/openerp-command/trunk-better_help-cto
Merge into: lp:openerp-command
Diff against target: 72 lines (+40/-6)
2 files modified
openerpcommand/__init__.py (+36/-6)
openerpcommand/run_tests.py (+4/-0)
To merge this branch: bzr merge lp:~openerp-dev/openerp-command/trunk-better_help-cto
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+132860@code.launchpad.net

Description of the change

Try to get a nicer help message for the standalone command --help

To post a comment you must log in.
183. By Samus CTO (OpenERP)

[FIX] Line wrap to 80

184. By Samus CTO (OpenERP)

[IMP] Description in a list var instead of a string + added a __doc__ for module run_tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerpcommand/__init__.py'
2--- openerpcommand/__init__.py 2012-08-23 09:25:05 +0000
3+++ openerpcommand/__init__.py 2012-11-05 11:33:19 +0000
4@@ -1,4 +1,5 @@
5 import argparse
6+import textwrap
7
8 from .call import Call
9 from .client import Open, Show, ConsumeNothing, ConsumeMemory, LeakMemory, ConsumeCPU
10@@ -17,15 +18,44 @@
11 from . import uninstall
12 from . import update
13
14+command_list_server = (conf, drop, initialize, model, module, read, run_tests,
15+ scaffold, uninstall, update, )
16+
17+command_list_client = (Call, Open, Show, ConsumeNothing, ConsumeMemory,
18+ LeakMemory, ConsumeCPU, Bench, BenchRead,
19+ BenchFieldsViewGet, BenchDummy, BenchLogin,
20+ BenchSaleMrp, )
21+
22 def main_parser():
23- parser = argparse.ArgumentParser()
24- subparsers = parser.add_subparsers()
25+ parser = argparse.ArgumentParser(
26+ usage=argparse.SUPPRESS,
27+ description=textwrap.fill(textwrap.dedent("""\
28+ OpenERP Command provides a set of command-line tools around
29+ the OpenERP framework: openobject-server. All the tools are
30+ sub-commands of a single oe executable.""")),
31+ epilog="""Use <command> --help to get information about the command.""",
32+ formatter_class=argparse.RawDescriptionHelpFormatter,
33+ )
34+ description = []
35+ for x in command_list_server:
36+ description.append(x.__name__[len(__package__)+1:])
37+ if x.__doc__:
38+ description.extend([
39+ ":\n",
40+ textwrap.fill(str(x.__doc__).strip(),
41+ subsequent_indent=' ',
42+ initial_indent=' '),
43+ ])
44+ description.append("\n\n")
45+ subparsers = parser.add_subparsers(
46+ title="Available commands",
47+ help=argparse.SUPPRESS,
48+ description="".join(description[:-1]),
49+ )
50 # Server-side commands.
51- for x in (conf, drop, initialize, model, module, read, run_tests, scaffold, uninstall, update,):
52+ for x in command_list_server:
53 x.add_parser(subparsers)
54 # Client-side commands. TODO one per .py file.
55- for x in (Call, Open, Show, ConsumeNothing, ConsumeMemory, LeakMemory, ConsumeCPU,
56- Bench, BenchRead, BenchFieldsViewGet, BenchDummy, BenchLogin,
57- BenchSaleMrp):
58+ for x in command_list_client:
59 x(subparsers)
60 return parser
61
62=== modified file 'openerpcommand/run_tests.py'
63--- openerpcommand/run_tests.py 2012-10-09 12:34:39 +0000
64+++ openerpcommand/run_tests.py 2012-11-05 11:33:19 +0000
65@@ -1,3 +1,7 @@
66+"""
67+Execute the unittest2 tests available in OpenERP addons.
68+"""
69+
70 import os
71 import sys
72 import types

Subscribers

People subscribed via source and target branches