示例#1
0
 def format_commands(
     self, ctx: click.core.Context, formatter: click.formatting.HelpFormatter
 ):
     for title, groups in self.groups:
         for group in groups:
             formatter.write(click.style(f"\n{title} from {group.name}", fg="green"))
             group.format_commands(ctx, formatter)
示例#2
0
文件: command.py 项目: zen-xu/comeon
    def format_options(self, ctx: click.Context,
                       formatter: click.formatting.HelpFormatter) -> None:
        """Writes all the options into the formatter if they exist."""
        opts = []
        for param in self.get_params(ctx):
            help_record = param.get_help_record(ctx)
            if help_record is None:
                continue
            rv, help = help_record
            rv = click.style(rv, fg=self.options_color)
            help = click.style(help, fg=self.options_help_color)
            if rv is not None:
                opts.append((rv, help))

        if opts:
            with formatter.section("Options"):
                formatter.write_dl(opts)
示例#3
0
    def format_help_text(self, ctx: click.Context,
                         formatter: click.formatting.HelpFormatter):
        """
		Writes the help text to the formatter if it exists.

		:param ctx:
		:param formatter:
		"""

        formatter.write('\n')
        formatter.write(indent((self.help or ''), "  "))
        formatter.write('\n')
示例#4
0
    def format_help_text(self, ctx: click.Context,
                         formatter: click.formatting.HelpFormatter):
        """
		Writes the help text to the formatter if it exists.

		:param ctx:
		:param formatter:
		"""

        doc = block_token.Document(self.help or '')

        with TerminalRenderer() as renderer:
            rendered_doc = indent(renderer.render(doc).strip(), "  ")

        if resolve_color_default(self._colour) is False:
            # Also remove 'COMBINING LONG STROKE OVERLAY', used for strikethrough.
            rendered_doc = strip_ansi(rendered_doc).replace('̶', '')

        formatter.write('\n')
        formatter.write(rendered_doc)
        formatter.write('\n')