示例#1
0
 def load_vendors(self):
     """ associate vendor  to their scheme
     each vendor should contain a scheme list and a callable that should be named
     fetch. 
     Scheme is anything before "://" .
     
     ex:
     
         def fetch(ui, url, path, *args, **opts):
             ...
             
         scheme = ['git', 'git+ssh']
         
     See gitvendor module for more info.
     
     """
     scheme = {}
     vendors = []
     for name, mod in get_extensions():
         if not hasattr(mod, 'fetch') or not hasattr(mod, 'scheme'):
             continue
         else:
             vendors.append((getattr(mod, '__extension_name__', name), 
                             getattr(mod, '___copyright__', ""), 
                             getattr(mod, '__doc__', "")))
             
             fetchcmd = getattr(mod, 'fetch')
             for s in getattr(mod, 'scheme'):
                 scheme[s] = fetchcmd
     return scheme, vendors
示例#2
0
def usage(ui, *args, **opts):
    if opts.get('version', False):
        version(ui, *args, **opts)
    print "couchapp [OPTIONS] [CMD] [OPTIONSCMD] [ARGS,...]"
    print "usage:"
    print ""

    mainopts = []
    for opt in globalopts:
        print_option(opt)
        mainopts.append(opt[0])
        
    print ""
    print "list of commands:"
    print "-----------------"
    print ""
    for cmd in sorted(table.keys()):
        opts = table[cmd]
        print "%s\t %s" % (cmd, opts[2])
        for opt in opts[1]:
            print_option(opt)
        print ""
    print "loaded extensions:"
    print "------------------"
    print ""
    for name, mod in get_extensions():
        name = getattr(mod, '__extension_name__', name)
        print "%s" % name
    print ""
    return 0
示例#3
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)