Esempio n. 1
0
def _dispatch(args):
    conf = Config()

    # update commands
    for mod in conf.extensions:
        cmdtable = getattr(mod, 'cmdtable', {})
        commands.table.update(cmdtable)
        
    cmd, globalopts, opts, args = _parse(args)
        
    if globalopts["help"]:
        del globalopts["help"]
        return commands.usage(conf, *args, **globalopts)
    elif globalopts["version"]:
        del globalopts["version"]
        return commands.version(conf, *args, **globalopts)
    
    verbose = 2
    if globalopts["verbose"]:
        verbose = 1
    elif globalopts["quiet"]:
        verbose = 0
        
    set_logging_level(verbose)
    if cmd is None:
        raise CommandLineError("unknown command")

    fun = commands.table[cmd][0]
    if cmd in commands.incouchapp:
         return fun(conf, conf.app_dir, *args, **opts)    
    
    return fun(conf, *args, **opts)    
Esempio n. 2
0
def _dispatch(ui, args):
    # if we are in a couchapp path is not None
    path = _findcouchapp(os.getcwd())
    if path is not None:
        ui.updateconfig(path)
    
    # load extensions
    load_extensions(ui)
    # update commands
    for name, mod in get_extensions():
        cmdtable = getattr(mod, 'cmdtable', {})
        commands.table.update(cmdtable)
        
    cmd, globalopts, opts, args = _parse(ui, args)
        
    if globalopts["help"]:
        del globalopts["help"]
        return commands.usage(ui, *args, **globalopts)
    elif globalopts["version"]:
        del globalopts["version"]
        return commands.version(ui, *args, **globalopts)
    
    verbose = 1
    if globalopts["verbose"]:
        verbose = 2
    elif globalopts["quiet"]:
        verbose = 0
        
    ui.set_verbose(verbose)
    if cmd is None:
        raise CommandLineError("unknown command")

    fun = commands.table[cmd][0]
    if cmd in commands.incouchapp:
         return fun(ui, path, *args, **opts)    
    
    return fun(ui, *args, **opts)    
Esempio n. 3
0
def _dispatch(args):
    conf = Config()

    # update commands
    for mod in conf.extensions:
        cmdtable = getattr(mod, 'cmdtable', {})
        commands.table.update(cmdtable)

    cmd, globalopts, opts, args = _parse(args)

    if globalopts["help"]:
        del globalopts["help"]
        return commands.usage(conf, *args, **globalopts)
    elif globalopts["version"]:
        del globalopts["version"]
        return commands.version(conf, *args, **globalopts)

    verbose = 2
    if globalopts["debug"]:
        verbose = 1
        import restkit
        restkit.set_logging("debug")
    elif globalopts["verbose"]:
        verbose = 1
    elif globalopts["quiet"]:
        verbose = 0

    set_logging_level(verbose)
    if cmd is None:
        raise CommandLineError("unknown command")

    fun = commands.table[cmd][0]
    if cmd in commands.incouchapp:
        return fun(conf, conf.app_dir, *args, **opts)

    return fun(conf, *args, **opts)
Esempio n. 4
0
def test_version_help():
    '''
    $ couchapp version -h
    '''
    assert commands.version(Mock(), help=True) == 0