Example #1
0
 def format_options(self, ctx: click.Context,
                    formatter: click.HelpFormatter) -> None:
     self.format_commands(ctx, formatter)
     formatter.write_paragraph()
     formatter.write_text(
         f'Use "{ctx.info_name} help <command>" for more information '
         "about a given command or topic.")
     formatter.write_text(
         f'Use "{ctx.info_name} --options" for a list of global command-line '
         "options (applies to all commands).")
Example #2
0
 def format_options(self, ctx: click.Context,
                    formatter: click.HelpFormatter) -> None:
     self.format_commands(ctx, formatter)
     formatter.write_paragraph()
     formatter.write_text(
         'Use "neuro <command> --help" for more information about a given command.'
     )
     formatter.write_text(
         'Use "neuro --options" for a list of global command-line options '
         "(applies to all commands).")
Example #3
0
    def format_help_text(self, ctx: click.Context,
                         formatter: click.HelpFormatter) -> None:
        formatter.write_paragraph()
        alias_cmd = self.alias["exec"]
        formatter.write_text("Alias for " +
                             click.style(f'"{alias_cmd}"', bold=True))

        help = self.alias.get("help")
        if help is not None:
            formatter.write("\n")
            formatter.write_text(help)
Example #4
0
    def format_help_text(self, ctx: click.Context,
                         formatter: click.HelpFormatter) -> None:
        """Writes the help text to the formatter if it exists."""
        help = self.help  # type: ignore
        deprecated = self.deprecated  # type: ignore
        if help:
            help_text, *examples = split_examples(help)
            if help_text:
                formatter.write_paragraph()
                with formatter.indentation():
                    if deprecated:
                        help_text += DEPRECATED_HELP_NOTICE
                    formatter.write_text(help_text)
            examples = [example.strip() for example in examples]

            for example in examples:
                format_example(example, formatter)
        elif deprecated:
            formatter.write_paragraph()
            with formatter.indentation():
                formatter.write_text(DEPRECATED_HELP_NOTICE)
Example #5
0
 def format_options(self, ctx: click.Context, formatter: click.HelpFormatter) -> None:
     # Group options first
     groups = defaultdict(list)
     for param in self.get_params(ctx):
         rv = param.get_help_record(ctx)
         if rv is not None:
             if isinstance(param, GroupedOption):
                 group = param.group
             else:
                 group = ParameterGroup.generic
             groups[group].append(rv)
     # Then display groups separately with optional description
     for group in ParameterGroup:
         opts = groups[group]
         group_name, description = group.value
         with formatter.section(f"{group_name} options"):
             if description:
                 formatter.write_paragraph()
                 formatter.write_text(description)
                 formatter.write_paragraph()
             formatter.write_dl(opts)
Example #6
0
    def format_help(self, ctx: click.Context,
                    formatter: click.HelpFormatter) -> None:
        self.format_usage(ctx, formatter)
        formatter.write_paragraph()
        assert ctx.parent is not None
        alias_cmd = self.alias["cmd"]
        formatter.write(
            "Alias for " +
            click.style(f'"{ctx.parent.info_name} {alias_cmd}"', bold=True))
        formatter.write_paragraph()

        help = self.alias.get("help")
        if help is not None:
            formatter.write_paragraph()
            formatter.write_text(help)

        self.format_options(ctx, formatter)
Example #7
0
    def format_help_text(self, ctx: Context, formatter: Formatter) -> None:
        """ Writes the help text to the formatter if it exists. """

        formatter.write_paragraph()
        formatter.write_text(self.help)
Example #8
0
def format_help_text(text: str, formatter: click.HelpFormatter):
    text = inspect.cleandoc(text).partition("\f")[0]
    formatter.write_paragraph()

    with formatter.indentation():
        formatter.write_text(text)
 def format_help(self, ctx: click.Context, formatter: click.HelpFormatter) -> None:
     if self.help is None:
         return
     formatter.write_paragraph()
     formatter.write(apply_styling(self.help))