Ejemplo n.º 1
0
def add_plugins_args(f):
    """Adds installed plugin options."""
    schemas = []
    if isinstance(f, click.Command):
        for p in plugins.all():
            schemas.append(get_plugin_properties(p.json_schema))
        f.params.extend(params_factory(schemas))
    else:
        if not hasattr(f, "__click_params__"):
            f.__click_params__ = []

        for p in plugins.all():
            schemas.append(get_plugin_properties(p.json_schema))
        f.__click_params__.extend(params_factory(schemas))
    return f
Ejemplo n.º 2
0
def add_plugins_args(f):
    """Adds installed plugin options."""
    schemas = []
    if isinstance(f, click.Command):
        for p in plugins.all():
            schemas.append(get_plugin_properties(p.json_schema))
        f.params.extend(params_factory(schemas))
    else:
        if not hasattr(f, "__click_params__"):
            f.__click_params__ = []

        for p in plugins.all():
            schemas.append(get_plugin_properties(p.json_schema))
        f.__click_params__.extend(params_factory(schemas))
    return f
Ejemplo n.º 3
0
def list_plugins():
    """Shows all available plugins"""
    table = []
    for p in plugins.all():
        table.append([p.title, p.slug, p.version, p.author, p.description])
    click.echo(
        tabulate(table, headers=["Title", "Slug", "Version", "Author", "Description"])
    )
Ejemplo n.º 4
0
def list_plugins():
    """Shows all available plugins"""
    table = []
    for p in plugins.all():
        table.append([p.title, p.slug, p.version, p.author, p.description])
    click.echo(
        tabulate(table, headers=["Title", "Slug", "Version", "Author", "Description"])
    )
Ejemplo n.º 5
0
def get_plugin_callback(ctx: object, param: str, value: str) -> object:
    """Ensures that the plugin selected is available."""
    for p in plugins.all(plugin_type=param.name.split("_")[0]):
        if p.slug == value:
            return {"plugin": p, "options": {}}

    raise click.BadParameter(
        f"Could not find appropriate plugin. Param: {param.name} Value: {value}"
    )
Ejemplo n.º 6
0
def get_plugin_callback(ctx: object, param: str, value: str) -> object:
    """Ensures that the plugin selected is available."""
    for p in plugins.all(plugin_type=param.name.split("_")[0]):
        if p.slug == value:
            return {"plugin": p, "options": {}}

    raise click.BadParameter(
        f"Could not find appropriate plugin. Param: {param.name} Value: {value}"
    )
Ejemplo n.º 7
0
def list_plugins():
    """Shows all available plugins"""
    table = []
    for p in plugins.all():
        table.append([p.title, p.slug, p.version, p.author, p.description])
    click.echo(
        tabulate(table,
                 headers=['Title', 'Slug', 'Version', 'Author',
                          'Description']))
Ejemplo n.º 8
0
def plugin_command_factory():
    """Dynamically generate plugin groups for all plugins, and add all basic command to it"""
    for p in plugins.all():
        plugin_name = p.slug
        help = f"Options for '{plugin_name}'"
        group = click.Group(name=plugin_name, help=help)
        for name, description in CORE_COMMANDS.items():
            callback = func_factory(p, name)
            pretty_opt = click.Option(['--pretty/--not-pretty'], help='Output a pretty version of the JSON')
            params = [pretty_opt]
            command = click.Command(name, callback=callback, help=description.format(plugin_name), params=params)
            group.add_command(command)

        plugins_group.add_command(group)
Ejemplo n.º 9
0
def plugin_command_factory():
    """Dynamically generate plugin groups for all plugins, and add all basic command to it"""
    for p in plugins.all():
        plugin_name = p.slug
        help = f"Options for '{plugin_name}'"
        group = click.Group(name=plugin_name, help=help)
        for name, description in CORE_COMMANDS.items():
            callback = func_factory(p, name)
            pretty_opt = click.Option(
                ['--pretty/--not-pretty'],
                help='Output a pretty version of the JSON')
            params = [pretty_opt]
            command = click.Command(name,
                                    callback=callback,
                                    help=description.format(plugin_name),
                                    params=params)
            group.add_command(command)

        plugins_group.add_command(group)
Ejemplo n.º 10
0
def list_plugins():
    """Shows all available plugins"""
    table = []
    for p in plugins.all():
        table.append([p.title, p.slug, p.version, p.author, p.description])
    click.echo(tabulate(table, headers=['Title', 'Slug', 'Version', 'Author', 'Description']))