async def command(ctx, indexes, update): full = True bring = await self.get_bring() if len(indexes) == 1: console.line() idx = await bring.get_index(index_name=indexes[0]) display = IndexExplanation( name=indexes[0], data=idx, update=update, full_info=full ) console.print(display) return if not indexes: indexes = bring.index_ids full = False info_items = [] for index in indexes: idx = await bring.get_index(index_name=index) display = IndexExplanation( name=index, data=idx, update=update, full_info=full ) info_items.append(display) expl = InfoListExplanation(*info_items, full_info=full) console.print(expl)
async def plugin_command(ctx): all = [] doc = self.get_plugin_doc(name) doc.extract_metadata("examples") desc_string = f"## Mogrifier: **{name}**\n" if doc.get_short_help(default=None): desc_string += doc.get_short_help() + "\n\n" desc_string += f"\n## Input Arguments\n\nThis is the list of arguments the *{name}* mogrifier accepts as input:\n" desc = Markdown( desc_string, style=bring_style, code_theme=bring_code_theme, justify="left", ) all.append(desc) plugin = self.get_plugin(name) if hasattr(plugin, "_requires"): args = plugin._requires else: args = plugin.requires(None) record_arg = self._arg_hive.create_record_arg(childs=args) arg_table = to_rich_table(record_arg) all.append(arg_table) desc_string = f"\n## Output Arguments\n\nThis is the list of arguments the *{name}* mogrifier provides as output:\n" desc = Markdown( desc_string, style=bring_style, code_theme=bring_code_theme, justify="left", ) all.append(desc) if hasattr(plugin, "_provides"): args = plugin._provides else: args = plugin.provides(None) record_arg = self._arg_hive.create_record_arg(childs=args) arg_table = to_rich_table(record_arg) all.append(arg_table) desc_string = await create_pkg_type_markdown_string( bring=self.bring, plugin_doc=doc) desc = Markdown( desc_string, style=bring_style, code_theme=bring_code_theme, justify="left", ) all.append(desc) group = RenderGroup(*all) console.print(Panel(Panel(group, box=box.SIMPLE)))
async def info( ctx, self, update: bool = False, full: bool = False, args: bool = False ): self._pkg_info.update = update self._pkg_info.display_full_args = args self._pkg_info.display_full = full console.print(self._pkg_info)
async def command(ctx, **kwargs): console.line() arg_value = args_renderer.create_arg_value(kwargs) frecklet.input_sets.add_input_values( _id="cli_input", **arg_value.processed_input) explanation = frecklet.explain() console.print(explanation)
async def command(ctx): console.line() ce = ContextExplanation( name=self.name, data=self._bring_context, full_info=True, show_title=True, ) console.print(ce)
async def show_details(ctx, self): if ctx.invoked_subcommand is not None: return console.line() ce = ContextExplanation( name=self.name, data=self._bring_context, full_info=True, show_title=True ) console.print(ce)
async def command(ctx, package, update, args): bring = await self.get_bring() console.line() # await self._bring.add_indexes("kubernetes", "binaries") pkg = await bring.get_pkg(name=package, raise_exception=True) pkg_info: PkgInfoDisplay = PkgInfoDisplay( data=pkg, update=update, full_info=True, display_full_args=args ) console.print(pkg_info)
async def show_current(ctx, full: bool): """Show details for the current config context. This takes into account the provided gloabl arguments for this commandline invocation. """ self._bring_config.set_config(*self._config_list) c = await self._bring_config.get_config_dict() config_explanation = ArgsExplanation( c, BRING_CONFIG_SCHEMAN, arg_hive=self._arg_hive, full_details=full ) console.line() console.print(config_explanation)
async def explain_contexts( contexts: Mapping[str, ConfigTing], full_info: bool = False ) -> None: explanations = [] for ctx_name, context in contexts.items(): ce = ContextExplanation( data=context, name=ctx_name, full_info=full_info, show_title=False ) explanations.append(ce) exp_list = InfoListExplanation(*explanations, full_info=full_info) console.print(exp_list)
async def command(ctx, **kwargs): arg_value = args_renderer.create_arg_value(kwargs) frecklet.input_sets.add_input_values( _id="cli_input", **arg_value.processed_input) console.line() msg = await frecklet.get_msg() console.print(f"[title]Task[/title]: {msg}") console.line() console.print("[title]Variables[/title]:") pi = frecklet.input_sets.explain() console.print(pi) result = await frecklet.get_frecklet_result() console.print("[title]Result:[/title]") console.print(result)
async def plugin_command(ctx): all = [] doc = self.get_plugin_doc(name) doc.extract_metadata("examples") desc_string = f"## Package type: **{name}**\n" if doc.get_short_help(default=None): desc_string += doc.get_short_help() + "\n\n" desc_string += f"\n## Arguments\n\nThis is the list of arguments that can be used to describe a package of the *{name}* type:\n" desc = Markdown( desc_string, style=bring_style, code_theme=bring_code_theme, justify="left", ) all.append(desc) plugin = self.get_plugin(name) args = plugin.get_args() record_arg = self._arg_hive.create_record_arg(childs=args) arg_table = to_rich_table(record_arg) all.append(arg_table) desc_string = await create_pkg_type_markdown_string( bring=self.bring, plugin_doc=doc) desc = Markdown( desc_string, style=bring_style, code_theme=bring_code_theme, justify="left", ) all.append(desc) group = RenderGroup(*all) console.print(Panel(Panel(group, box=box.SIMPLE)))
async def export_index(ctx, self, output_file, index: str, force: bool, check: bool): click.echo() _index = os.path.abspath(os.path.expanduser(index)) if not os.path.isdir(os.path.realpath(_index)): click.echo( f"Can't export index '{index}': path does not exist or not a folder" ) sys.exit(1) if output_file is None: _path = os.path.join(_index, BRING_METADATA_FOLDER_NAME, DEFAULT_FOLDER_INDEX_NAME) elif os.path.isdir(os.path.realpath(output_file)): click.echo( f"Can't write index file, specified output file is a folder: {output_file}" ) else: _path = os.path.abspath(os.path.expanduser(output_file)) index_obj = await self._bring.get_index(_index) exported_index = await index_obj.export_index() empty: bool = True for k in exported_index.keys(): if not k.startswith("_"): empty = False break if empty: click.echo("Index does not contain any packages, doing nothing...") sys.exit(1) inconsistent: Iterable[str] = [] if os.path.exists(_path): old_index = await self._bring.get_index(_path) diff = IndexDiff(old_index, index_obj) inconsistent = await diff.get_inconsistent_package_names() if inconsistent: if not force: console.print( f"[red bold]Can't update index, inconsistencies exist for package(s): {', '.join(sorted(inconsistent))}[/red bold]" ) else: console.print( f"Force update old index, even though are inconsistencies for packages: {', '.join(sorted(inconsistent))}" ) else: console.print("Older index file exists, no inconsistencies.") console.line() console.print("Details:") console.line() console.print(diff) else: console.print("No previous index file exists, writing new one...") ensure_folder(os.path.dirname(_path)) if inconsistent and not force: sys.exit(1) if not check: console.line() console.print(f"Exporting index to file: {_path}") json_data = json.dumps(exported_index, indent=2) + "\n" json_bytes = json_data.encode("utf-8") with gzip.GzipFile(_path, "w") as f: f.write(json_bytes)
async def command(ctx, path): if path is None: path = os.path.abspath(".").split(os.path.sep)[0] + os.path.sep target = TrackingLocalFolder(path=path) console.print(target.explain())
async def info(ctx, self, update: bool = False, full: bool = False): self._index_info.update = update self._index_info.display_full = full console.print(self._index_info)