5 from openerp import tools
6 from openerp.modules import module
8 _logger = logging.getLogger(__name__)
12 class CommandType(type):
13 def __init__(cls, name, bases, attrs):
14 super(CommandType, cls).__init__(name, bases, attrs)
15 name = getattr(cls, name, cls.__name__.lower())
20 class Command(object):
21 """Subclass this class to define new openerp subcommands """
22 __metaclass__ = CommandType
29 print "Available commands:\n"
30 for k, v in commands.items():
38 # The only shared option is '--addons-path=' needed to discover additional
39 # commands from modules
40 if len(args) > 1 and args[0].startswith('--addons-path=') and not args[1].startswith("-"):
41 tools.config.parse_config([args[0]])
44 # Default legacy command
47 # Subcommand discovery
48 if len(args) and not args[0].startswith("-"):
49 for m in module.get_modules():
50 m = 'openerp.addons.' + m
59 if command in commands:
60 o = commands[command]()