Esempio n. 1
0
def protocols(ctx: Context, query):
    """Search for Protocols."""
    if ctx.config.get("is_registry"):
        click.echo('Searching for "{}"...'.format(query))
        resp = request_api("GET", "/protocols", params={"search": query})
        if len(resp) == 0:
            click.echo("No protocols found.")  # pragma: no cover
        else:
            click.echo("Protocols found:\n")
            click.echo(_format_items(resp))
        return

    registry = cast(str, ctx.config.get("registry_directory"))
    result = []  # type: List[Dict]
    _get_details_from_dir(
        ctx.protocol_loader, AEA_DIR, "protocols", DEFAULT_PROTOCOL_CONFIG_FILE, result
    )
    _get_details_from_dir(
        ctx.protocol_loader,
        registry,
        "*/protocols",
        DEFAULT_PROTOCOL_CONFIG_FILE,
        result,
    )

    print("Available protocols:")
    print(_format_items(sorted(result, key=lambda k: k["name"])))
Esempio n. 2
0
def agents(ctx: Context, query):
    """Search for Agents."""
    if ctx.config.get("is_registry"):
        resp = request_api("GET", "/agents", params={"search": query})
        if len(resp) == 0:
            click.echo("No agents found.")  # pragma: no cover
        else:
            click.echo("Agents found:\n")
            click.echo(_format_items(resp))
        return
    else:
        registry = cast(str, ctx.config.get("registry_directory"))
        result = []  # type: List[Dict]
        _get_details_from_dir(
            ctx.agent_loader, registry, "agents", DEFAULT_AEA_CONFIG_FILE, result
        )

        print("Available agents:")
        print(_format_items(sorted(result, key=lambda k: k["name"])))
Esempio n. 3
0
def agents(ctx: Context, query):
    """Search for Agents."""
    click.echo('Searching for "{}"...'.format(query))
    if ctx.config.get("is_local"):
        results = _search_items(ctx, "agents")
    else:
        results = request_api("GET", "/agents", params={"search": query})

    if not len(results):
        click.echo("No agents found.")  # pragma: no cover
    else:
        click.echo("Agents found:\n")
        click.echo(_format_items(results))
Esempio n. 4
0
 def test_format_items_positive(self):
     """Test format_items positive result."""
     items = [{
         "public_id": "author/name:version",
         "name": "obj-name",
         "description": "Some description",
         "author": "author",
         "version": "1.0",
     }]
     result = _format_items(items)
     expected_result = ("------------------------------\n"
                        "Public ID: author/name:version\n"
                        "Name: obj-name\n"
                        "Description: Some description\n"
                        "Author: author\n"
                        "Version: 1.0\n"
                        "------------------------------\n")
     self.assertEqual(result, expected_result)
Esempio n. 5
0
def skills(ctx: Context):
    """List all the installed skills."""
    result = _get_item_details(ctx, "skill")
    print(_format_items(sorted(result, key=lambda k: k["name"])))
Esempio n. 6
0
def connections(ctx: Context):
    """List all the installed connections."""
    result = _get_item_details(ctx, "connection")
    print(_format_items(sorted(result, key=lambda k: k["name"])))