Skip to content

CommandCollection doesn't run the callback from original group #1179

Closed

Description

We have plugins that export a click group which we pull into our command line by composing them together with a CommandCollection. However some of the plugins do important setup in their group callbacks and the CommandCollection doesn't run those.
We've fixed this by replacing the CommandCollection's callback with the group's callback in get_command. I don't know Click well enough to know if this is right but it makes sense to me.

    def get_command(self, ctx, cmd_name):
        for source in self.sources:
            cmd = source.get_command(ctx, cmd_name)
            if cmd is not None:
                self.callback = source.callback
                return cmd
        return None

Activity

  1. jcrotts commented on May 7, 2019

    @jcrotts
    Contributor

    Closing this, as I think it is a duplicate issue of #347 .

    Thanks for the work around though, that is helpful. Please reopen if I have misunderstood.

  2. locked as resolved and limited conversation to collaborators on Jun 2, 2021
  3. added
    parsingParsing, parameters, commands, chaining, context
    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

    parsingParsing, parameters, commands, chaining, context

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions