devtools/devctl.py
branchstable
changeset 6143 d7d2edf70011
parent 6138 65f5e488f983
child 6356 e89f71a41e20
equal deleted inserted replaced
6137:b33d32f28885 6143:d7d2edf70011
    29 from os import mkdir, chdir
    29 from os import mkdir, chdir
    30 from os.path import join, exists, abspath, basename, normpath, split, isdir
    30 from os.path import join, exists, abspath, basename, normpath, split, isdir
    31 from warnings import warn
    31 from warnings import warn
    32 
    32 
    33 from logilab.common import STD_BLACKLIST
    33 from logilab.common import STD_BLACKLIST
    34 from logilab.common.clcommands import register_commands, pop_arg
       
    35 
    34 
    36 from cubicweb.__pkginfo__ import version as cubicwebversion
    35 from cubicweb.__pkginfo__ import version as cubicwebversion
    37 from cubicweb import CW_SOFTWARE_ROOT as BASEDIR, BadCommandUsage
    36 from cubicweb import CW_SOFTWARE_ROOT as BASEDIR, BadCommandUsage
       
    37 from cubicweb.cwctl import CWCTL
    38 from cubicweb.toolsutils import (SKEL_EXCLUDE, Command,
    38 from cubicweb.toolsutils import (SKEL_EXCLUDE, Command,
    39                                  copy_skeleton, underline_title)
    39                                  copy_skeleton, underline_title)
    40 from cubicweb.web.webconfig import WebConfiguration
    40 from cubicweb.web.webconfig import WebConfiguration
    41 from cubicweb.server.serverconfig import ServerConfiguration
    41 from cubicweb.server.serverconfig import ServerConfiguration
    42 
    42 
   682 
   682 
   683 class GenerateSchema(Command):
   683 class GenerateSchema(Command):
   684     """Generate schema image for the given cube"""
   684     """Generate schema image for the given cube"""
   685     name = "schema"
   685     name = "schema"
   686     arguments = '<cube>'
   686     arguments = '<cube>'
       
   687     min_args = max_args = 1
   687     options = [('output-file', {'type':'file', 'default': None,
   688     options = [('output-file', {'type':'file', 'default': None,
   688                  'metavar': '<file>', 'short':'o', 'help':'output image file',
   689                  'metavar': '<file>', 'short':'o', 'help':'output image file',
   689                  'input':False}),
   690                  'input':False}),
   690                ('viewer', {'type': 'string', 'default':None,
   691                ('viewer', {'type': 'string', 'default':None,
   691                 'short': "d", 'metavar':'<cmd>',
   692                 'short': "d", 'metavar':'<cmd>',
   718         from tempfile import NamedTemporaryFile
   719         from tempfile import NamedTemporaryFile
   719         from logilab.common.textutils import splitstrip
   720         from logilab.common.textutils import splitstrip
   720         from yams import schema2dot, BASE_TYPES
   721         from yams import schema2dot, BASE_TYPES
   721         from cubicweb.schema import (META_RTYPES, SCHEMA_TYPES, SYSTEM_RTYPES,
   722         from cubicweb.schema import (META_RTYPES, SCHEMA_TYPES, SYSTEM_RTYPES,
   722                                      WORKFLOW_TYPES, INTERNAL_TYPES)
   723                                      WORKFLOW_TYPES, INTERNAL_TYPES)
   723         cubes = splitstrip(pop_arg(args, 1))
   724         cubes = splitstrip(args[0])
   724         dev_conf = DevConfiguration(*cubes)
   725         dev_conf = DevConfiguration(*cubes)
   725         schema = dev_conf.load_schema()
   726         schema = dev_conf.load_schema()
   726         out, viewer = self['output-file'], self['viewer']
   727         out, viewer = self['output-file'], self['viewer']
   727         if out is None:
   728         if out is None:
   728             tmp_file = NamedTemporaryFile(suffix=".svg")
   729             tmp_file = NamedTemporaryFile(suffix=".svg")
   749 
   750 
   750     def run(self, args):
   751     def run(self, args):
   751         from cubicweb.devtools.qunit import make_qunit_html
   752         from cubicweb.devtools.qunit import make_qunit_html
   752         print make_qunit_html(args[0], args[1:])
   753         print make_qunit_html(args[0], args[1:])
   753 
   754 
   754 register_commands((UpdateCubicWebCatalogCommand,
   755 for cmdcls in (UpdateCubicWebCatalogCommand,
   755                    UpdateTemplateCatalogCommand,
   756                UpdateTemplateCatalogCommand,
   756                    #LiveServerCommand,
   757                #LiveServerCommand,
   757                    NewCubeCommand,
   758                NewCubeCommand,
   758                    ExamineLogCommand,
   759                ExamineLogCommand,
   759                    GenerateSchema,
   760                GenerateSchema,
   760                    GenerateQUnitHTML,
   761                GenerateQUnitHTML,
   761                    ))
   762                ):
       
   763     CWCTL.register(cmdcls)