def search(part_match): header_len = len(_HEADER_PART_NAME) matches, part_length = _RemoteParts().matches_for(part_match, header_len) terminal_width = get_terminal_width(max_width=None) part_length = max(part_length, header_len) # <space> + <space> + <description> + ... = 5 description_space = terminal_width - part_length - 5 if not matches: # apt search does not return error, we probably shouldn't either. logger.info( "No matches found, try to run `snapcraft update` to " "refresh the remote parts cache." ) return print( "{} {}".format(_HEADER_PART_NAME.ljust(part_length, " "), _HEADER_DESCRIPTION) ) for part_key in sorted(matches.keys()): description = matches[part_key]["description"].split("\n")[0] if len(description) > description_space: description = "{}...".format(description[0:description_space]) print("{} {}".format(part_key.ljust(part_length, " "), description))
def _list_plugins(): plugins = [] for importer, modname, is_package in pkgutil.iter_modules( snapcraft.plugins.__path__): plugins.append(modname.replace('_', '-')) # we wrap the output depending on terminal size width = get_terminal_width() for line in format_output_in_columns(plugins, max_width=width): print(line)
def list_plugins(): """List the available plugins that handle different types of part. This command has an alias of `plugins`. """ plugins = [] for importer, modname, is_package in pkgutil.iter_modules( snapcraft.plugins.__path__): plugins.append(modname.replace('_', '-')) # we wrap the output depending on terminal size width = get_terminal_width() for line in format_output_in_columns(plugins, max_width=width): click.echo(line)
def list_plugins(): """List the available plugins that handle different types of part. This command has an alias of `plugins`. """ plugins = [] for _, modname, _ in pkgutil.iter_modules(snapcraft.plugins.v1.__path__): # Only add non-private modules/packages to the plugin list if not modname.startswith("_"): plugins.append(modname.replace("_", "-")) # we wrap the output depending on terminal size width = get_terminal_width() for line in format_output_in_columns(plugins, max_width=width): click.echo(line)
def list_plugins(): """List the available plugins that handle different types of part. This command has an alias of `plugins`. """ plugins = [] for _, modname, _ in pkgutil.iter_modules( snapcraft.plugins.__path__): # Only add non-private modules/packages to the plugin list if not modname.startswith('_'): plugins.append(modname.replace('_', '-')) # we wrap the output depending on terminal size width = get_terminal_width() for line in format_output_in_columns(plugins, max_width=width): click.echo(line)
def list_plugins(base): """List the available plugins that handle different types of part. This command has an alias of `plugins`. """ if base is None: base = _try_get_base_from_project() plugins = [] for _, modname, _ in _get_modules_iter(base): # Only add non-private modules/packages to the plugin list if not modname.startswith("_"): plugins.append(modname.replace("_", "-")) # we wrap the output depending on terminal size width = get_terminal_width() click.echo(f"Displaying plugins available for {base!r}") for line in format_output_in_columns(plugins, max_width=width): click.echo(line)