Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing callable as help epilog #2655

Closed
forman opened this issue Dec 22, 2023 · 1 comment
Closed

Allow passing callable as help epilog #2655

forman opened this issue Dec 22, 2023 · 1 comment

Comments

@forman
Copy link

forman commented Dec 22, 2023

I'd like to have the option to also pass a function to the epilog kwarg instead of a str only:

def fetch_epilog() -> str:
    # Here: fetch/load/construct the epilog.
    # Function is called only if "--help" option is used.

@click.command(epilog=fetch_epilog)
def mycli():
    # ...

I don't want the epilog text to be available before help is needed because it

  1. takes a little time to construct it (e.g., due to imports of other packages);
  2. it occupies RAM (ok, not much, but still) which is only used when --help option is passed.

I'm happy to provide a PR should this feature request be accepted.

@davidism
Copy link
Member

I don't plan to add this level of complexity to this feature (and to all the other parts of help formatting as well). The Command class offers many methods that can be overridden to customize how help is constructed. You can override Command.format_epilog in this case.

@davidism davidism closed this as not planned Won't fix, can't repro, duplicate, stale Dec 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants