How to use the vcstool.clients.vcstool_clients function in vcstool

To help you get started, we’ve selected a few vcstool examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dirk-thomas / vcstool / vcstool / commands / custom.py View on Github external
def get_parser():
    parser = argparse.ArgumentParser(
        description='Run a custom command', prog='vcs custom')
    group = parser.add_argument_group(
        '"custom" command parameters restricting the repositories')
    for client_type in [
        c.type for c in vcstool_clients if c.type not in ['tar']
    ]:
        group.add_argument(
            '--' + client_type, action='store_true', default=False,
            help="Run command on '%s' repositories" % client_type)
    group = parser.add_argument_group('"custom" command parameters')
    group.add_argument(
        '--args', required=True, nargs='*', help='Arbitrary arguments passed '
        'to each vcs invocation. It must be passed after other arguments '
        'since it collects all following options.')
    return parser
github dirk-thomas / vcstool / vcstool / commands / help.py View on Github external
# help for a specific command
    if ns.command:
        # relay help request foe specific command
        entrypoint = get_entrypoint(ns.command)
        if not entrypoint:
            return 1
        return entrypoint(['--help'])

    # regular parsing validating options and arguments
    parser = get_parser()
    ns = parser.parse_args(args)

    if ns.clients:
        print('The available VCS clients are:')
        for client in vcstool_clients:
            print('  ' + client.type)
        return 0

    if ns.commands:
        print(' '.join([cmd.command for cmd in vcstool_commands]))
        return 0

    # output detailed command list
    parser = get_parser_with_command_only()
    parser.print_help()
    return 0
github dirk-thomas / vcstool / vcstool / commands / import_.py View on Github external
def generate_jobs(repos, args):
    jobs = []
    for path, repo in repos.items():
        path = os.path.join(args.path, path)
        clients = [c for c in vcstool_clients if c.type == repo['type']]
        if not clients:
            from vcstool.clients.none import NoneClient
            job = {
                'client': NoneClient(path),
                'command': None,
                'cwd': path,
                'output':
                    "Repository type '%s' is not supported" % repo['type'],
                'returncode': NotImplemented
            }
            jobs.append(job)
            continue

        client = clients[0](path)
        command = ImportCommand(
            args, repo['url'],
github dirk-thomas / vcstool / vcstool / commands / custom.py View on Github external
# should generate error due to missing --args
        parser.parse_known_args(args)

    client_args = args[index:]
    args = parser.parse_args(args[0:index])
    args.args = client_args

    # check if any client type is specified
    any_client_type = False
    for client in vcstool_clients:
        if client.type in args and args.__dict__[client.type]:
            any_client_type = True
            break
    # if no client type is specified enable all client types
    if not any_client_type:
        for client in vcstool_clients:
            if client.type in args:
                args.__dict__[client.type] = True

    command = CustomCommand(args)

    # filter repositories by specified client types
    clients = find_repositories(command.paths, nested=command.nested)
    clients = [c for c in clients if c.type in args and args.__dict__[c.type]]

    if command.output_repos:
        output_repositories(clients)
    jobs = generate_jobs(clients, command)
    results = execute_jobs(
        jobs, show_progress=True, number_of_workers=args.workers,
        debug_jobs=args.debug)