Esempio n. 1
0
def discover_project_actions():
    project_loader = ProjectLoader()

    try:
        project = project_loader.load('.')
        return project.actions
    except NotACpmProject:
        return []
Esempio n. 2
0
def execute(argv):
    create_parser = argparse.ArgumentParser(
        prog='cpm create',
        description='Create a new cpm project',
        add_help=False)
    create_parser.add_argument('project_name')
    create_parser.add_argument('-s',
                               '--no-sample-code',
                               required=False,
                               action='store_true',
                               default=False)
    args = create_parser.parse_args(argv)

    project_loader = ProjectLoader()
    service = CreationService(project_loader)

    options = CreationOptions(
        generate_sample_code=not args.no_sample_code,
        project_name=args.project_name,
        directory=args.project_name,
        init_from_existing_sources=False,
    )
    result = new_project(service, options)

    return result
Esempio n. 3
0
def execute(argv):
    install_bit_arg_parser = argparse.ArgumentParser(
        prog='cpm install', description='cpm Package Manager', add_help=False)
    install_bit_arg_parser.add_argument(
        '-s',
        '--repository-url',
        required=False,
        action='store',
        default='https://repo.cpmbits.com:8000')
    install_bit_arg_parser.add_argument('bit_name', nargs='?')
    args = install_bit_arg_parser.parse_args(argv)

    project_loader = ProjectLoader()
    bit_installer = BitInstaller(project_loader)
    user_configuration = CpmUserConfiguration()
    user_configuration.load()
    repository_url = args.repository_url if args.repository_url else user_configuration[
        "cpm_hub_url"]
    cpm_hub_connector = CpmHubConnectorV1(repository_url=f'{repository_url}')
    service = InstallService(project_loader, bit_installer, cpm_hub_connector)
    bit_name, bit_version = __bit_to_install(args.bit_name)

    if not args.bit_name:
        result = install_project_bits(service)
    else:
        result = install_bit(service, bit_name, bit_version)

    return result
Esempio n. 4
0
def execute(argv):
    create_parser = argparse.ArgumentParser(
        prog='cpm create',
        description='Create a new cpm project',
        add_help=False)
    create_parser.add_argument('project_name')
    create_parser.add_argument('-s',
                               '--repository-url',
                               required=False,
                               action='store',
                               default='https://repo.cpmbits.com:8000')
    create_parser.add_argument('-t',
                               '--template',
                               required=False,
                               action='store')
    args = create_parser.parse_args(argv)

    project_loader = ProjectLoader()
    cpm_hub_connector = CpmHubConnectorV1(repository_url=args.repository_url)
    service = CreationService(project_loader,
                              cpm_hub_connector=cpm_hub_connector)
    template_name, template_version = __template_to_use(args.template)

    options = CreationOptions(
        project_name=args.project_name,
        directory=args.project_name,
        init_from_existing_sources=False,
        init_from_template=True if args.template else False,
        template_name=template_name,
        template_version=template_version)
    result = new_project(service, options)

    return result
Esempio n. 5
0
def execute(argv):
    project_loader = ProjectLoader()
    cmakelists_builder = CMakeListsBuilder()
    project_builder = ProjectCommands()
    service = CompilationService(project_loader, cmakelists_builder,
                                 project_builder)

    result = clean_project(service)

    return result
Esempio n. 6
0
File: build.py Progetto: jamofer/cpm
def execute(argv):
    create_parser = argparse.ArgumentParser(prog='cpm build',
                                            description='cpm build',
                                            add_help=False)
    create_parser.add_argument('target', nargs='?', default='default')
    args = create_parser.parse_args(argv)

    project_loader = ProjectLoader()
    cmakelists_builder = CMakeListsBuilder()
    project_commands = ProjectCommands()
    service = CompilationService(project_loader, cmakelists_builder,
                                 project_commands)

    result = build_project(service, args.target)

    return result
Esempio n. 7
0
File: test.py Progetto: jamofer/cpm
def execute(argv):
    add_target_parser = argparse.ArgumentParser(
        prog='cpm test',
        description='cpm, modern C/C++ system',
        add_help=False)
    add_target_parser.add_argument('files_or_dirs', nargs=argparse.REMAINDER)
    args = add_target_parser.parse_args(argv)

    project_loader = ProjectLoader()
    cmakelists_builder = CMakeListsBuilder()
    project_commands = ProjectCommands()
    service = TestService(project_loader, cmakelists_builder, project_commands)

    result = run_tests(service, args.files_or_dirs)

    return result
Esempio n. 8
0
def execute(argv):
    create_parser = argparse.ArgumentParser(
        prog='cpm init',
        description='Initialize a project from existing sources',
        add_help=False)
    create_parser.add_argument('project_name')
    args = create_parser.parse_args(argv)

    project_loader = ProjectLoader()
    service = CreationService(project_loader)

    options = CreationOptions(init_from_existing_sources=True,
                              generate_sample_code=False,
                              directory='.',
                              project_name=args.project_name)
    result = init_project(service, options)

    return result