Skip to content

Allow epilog without indentation. #2881

Description

@Phrogz

When adding an epilog to a group, the text appears to be indented under the commands list.

@click.group(
    context_settings={"max_content_width": 100, "show_default": True},
    epilog="""\b
    Example Usage:
        # Run this stuff first
        $ some-command
        
        # Then run this command
        my-click-script go
    """,
)
def regression() -> None:
    """This is a tool with lots of commands."""
    pass
$ regression --help

Usage: regression [OPTIONS] COMMAND [ARGS]...

  This is a tool with lots of commands.

Options:
  --help  Show this message and exit.

Commands:
  bundle  Wrap it all up.
  guard   Run lots of verifications.
  report  Generate a report from a bundle.
  run     Do stuff.
  store   Don't use this; it's for CI/CD only.
  verify  Compare two reports and verify they are identical.

  Example Usage:
      # Run this stuff first
      $ some-command
      
      # Then run this command
      regression guard

I want the entire epilog to not be indented. Perhaps indent-epilog=False?

Activity

  1. Rowlando13 commented on Apr 11, 2025

    @Rowlando13
    Member

    I will keep an eye on this to see if it gathers community support.

  2. jpmvferreira commented on Jul 31, 2025

    @jpmvferreira

    It has my support! Is there a simple workaround for that in the meantime?

  3. sirosen commented on Mar 20, 2026

    @sirosen
    Contributor

    I just ran into a desire for this and solved it by making a customized copy of help_option to try to avoid some of the less clearly public APIs.

    def help_option(*, epilog: str | None = None) -> _t.Callable[[FC], FC]:
        """A variant of the built-in click ``--help`` option.
    
        Unlike ``click.help_option``, this decorator accepts its own `epilog` text which is
        printed *without indentation* after help text.
        """
    
        def show_help(ctx: click.Context, param: click.Parameter, value: bool) -> None:
            """Callback that print the help page on ``<stdout>`` and exits."""
            if value and not ctx.resilient_parsing:
                click.echo(ctx.get_help(), color=ctx.color)
                if epilog is not None:
                    formatter = ctx.make_formatter()
                    formatter.write_text(epilog)
                    click.echo("\n" + formatter.getvalue().rstrip("\n"), color=ctx.color)
                ctx.exit()
    
        return click.option(
            "-h",
            "--help",
            help="Show this message and exit.",
            callback=show_help,
            is_eager=True,
            expose_value=False,
            is_flag=True,
        )

    I'm not convinced in favor of a "dedent epilog" option -- that seems much too use-case specific. But I would like to be able to hook into this process to customize it more easily. In my example, I had to reproduce the whole help opt, with all of its details.

  4. added
    help outputHelp text formatting, layout, and --help rendering
    and removed on Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help outputHelp text formatting, layout, and --help rendering

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions