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
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
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"]) )
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"]) )
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}" )
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}" )
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']))
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)
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)
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']))